Macro to delete Blank Rows

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,701
Office Version
  1. 2019
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
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,388
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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.
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,751
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
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
 

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,701
Office Version
  1. 2019
Platform
  1. Windows
Thanks for you input Joe. Amended code, but still did not work
 

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,701
Office Version
  1. 2019
Platform
  1. Windows
Thanks Michael.Never thought of using autofilter to find the blank, which I would normally do


Your code works perfectly
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,388
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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 ..."
 

Watch MrExcel Video

Forum statistics

Threads
1,122,736
Messages
5,597,815
Members
414,178
Latest member
Octavian Manoli

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
Top