Delete rows if AF and AY empty but F has information

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?
 
G

Gord Dibben

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
 
L

Louie

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.
 
L

Louie

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.
 
G

Gord Dibben

Change the = 0 to < 2

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


Gord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top