Need Help Deleting Blank Rows

J

JCG

Greetings:

I have a spread sheet with data that has multiple blank rows that I would
like to delete with a macro. Each row of data is different with columns that
may or may not be blank. Therefore, I cannot search on a specific column to
delete the row. Any help is appreciated.
 
J

JLatham

We need some kind of rule to follow to decide if a row is considered 'blank'
or not. If not a single column, then perhaps empty cells in any one of
several different colums, as
if a4 is empty, or g4 is empty or i4 is empty, then delete row 4 completely,
or
a combination of columns, as
If a4 and i4 are empty, or g4 and k4 are empty, then delete row 4 completely.
 
J

JCG

Thanks for responding. The rule that will work with this spread sheet data
is "If there is NO data in columns A through AC, consider the row blank and
delete it" Can this be done? Thanks again...j
 
G

Gord Dibben

Sub DeleteRows_If_A_to_AC_MT()
Dim lRow As Long
Dim StartRow As Long
Dim EndRow As Long
StartRow = 1

EndRow = Cells(Rows.Count, 1).End(xlUp).Row

'EndRow = 1000

For lRow = EndRow To StartRow Step -1

If Application.CountA(Range(Cells(lRow, "A"), _
Cells(lRow, "AC"))) = 0 Then
Rows(lRow).Delete
End If
Next

End Sub


Gord Dibben MS Excel MVP
 

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