Macro to delete Blank Rows

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
I have written code to delte blank rows in Column D


I would like this to be amended to include empty rows in the column


Code:
Sub Del_Blanks()
On Error Resume Next
Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0
End Sub


Your assistance is most appreciated
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Any empty row will necessarily have an empty cell in col D so your code would delete the row except that your code is looking at col A, not D. Try Columns(4) for D.
 
Upvote 0
Umm, I would have thought after 5000 odd posts, this would be a no brainer for you !!
I'm assuming you mean cells that may have formulas that return a blank result ???

Code:
Sub MM1()
With Columns("D")
    .AutoFilter Field:=1, Criteria1:=""
    .Resize(Rows.Count - 1).Offset(1).EntireRow.Delete
    .AutoFilter
End With
End Sub
 
Upvote 0
Thanks for you input Joe. Amended code, but still did not work
 
Upvote 0
Thanks Michael.Never thought of using autofilter to find the blank, which I would normally do


Your code works perfectly
 
Upvote 0
Thanks for you input Joe. Amended code, but still did not work
Of course not, b/c your cells are not blank. They have a formula in them that's returning "" which you didn't tell us in your OP. As Michael noted in post #3 : "Umm, I would have thought after 5000 odd posts ..."
 
Upvote 0

Forum statistics

Threads
1,214,829
Messages
6,121,826
Members
449,051
Latest member
excelquestion515

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