deleting blank rows

mcorydon

New Member
Joined
Jan 6, 2014
Messages
16
Hello Guru's, I have a massive 1000+ row table in excel (A1:F1500) and I want to delete all of the blank rows. I know the F5, special, blanks trick but the problem is that some cells are blank while other cells in the same row have data. If I did the above trick it would eliminate E427 and A51 for example and that would mismatch the data (I don't want E428 being pushed into the E427 column) Any ideas? hope this made sense Thanks Y'all
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
This will Remove the entire row if any cells are blank:

Code:
Sub Ifsomeareblank()
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
    If Cells(i, 1) = "" Or Cells(i, 2) = "" Or Cells(i, 3) = "" Or Cells(i, 4) = "" Or Cells(i, 5) = "" _
    Or Cells(i, 6) = "" Or Cells(i, 7) = "" Or Cells(i, 8) = "" Or Cells(i, 9) = "" Or Cells(i, 10) = "" Then
    Range("A" & i).EntireRow.Delete shift:=xlUp
    End If
Next i
End Sub

This will only remove rows that are completely blank

Code:
Sub Ifallareblank()
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
    If Cells(i, 1) = "" And Cells(i, 2) = "" And Cells(i, 3) = "" And Cells(i, 4) = "" And Cells(i, 5) = "" _
    And Cells(i, 6) = "" And Cells(i, 7) = "" And Cells(i, 8) = "" And Cells(i, 9) = "" And Cells(i, 10) = "" Then
    Range("A" & i).EntireRow.Delete shift:=xlUp
    End If
Next i
End Sub
 
Upvote 0
Sorry I forgot to change the number of columns for you:
Code:
Sub Ifsomeareblank()
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
    If Cells(i, 1) = "" Or Cells(i, 2) = "" Or Cells(i, 3) = "" Or Cells(i, 4) = "" Or Cells(i, 5) = "" _
    Or Cells(i, 6) = "" Then
    Range("A" & i).EntireRow.Delete shift:=xlUp
    End If
Next i
End Sub

and:
Code:
Sub Ifallareblank()
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
    If Cells(i, 1) = "" And Cells(i, 2) = "" And Cells(i, 3) = "" And Cells(i, 4) = "" And Cells(i, 5) = "" _
    And Cells(i, 6) = "" Then
    Range("A" & i).EntireRow.Delete shift:=xlUp
    End If
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top