Delete rows if AF and AY empty but F has information

  • Thread starter Thread starter Louie
  • Start date Start date
L

Louie

I am looking for help getting a macro that works and performs the following
steps.

Check Column F for information
If Column F has information check Column AF and AY for information
If Column AF and AY are empty delete the rows.

Can you help?
 
Sub deleterows()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(i, "F").Value <> "" Then
If Application.CountA(Range(Cells(i, "AF"), _
Cells(i, "AY"))) = 0 Then
Rows(i).Delete
End If
End If
Next i

End Sub


Gord Dibben MS Excel MVP
 
Hi Gord thanks for the help. Its not working completely. Any thoughts?

Also, I am not sure if you saw my earlier post regarding this question.
After I realized I posted this question in the worksheet section, I left a
message to ignore this post, and I reposted in the programming section. The
title is 'Info in F but AF and/or AY no info so delete the..' but the
question is the same. My name is Louie, if you search by that display name
you will see the other post. Please reply wherever is more convenient for
you.

Thanks again for your help.
 
Miscommunication on my part. That's why its not working. Sorry Gord, i am
looking for "and/or", just ignore this post completely. My apologies.
 
Change the = 0 to < 2

If Application.CountA(Range(Cells(i, "AF"), _
Cells(i, "AY"))) = 0 Then


Gord
 
Back
Top