PDA

View Full Version : macro to delete row if cell is empty



killbill
02-06-2014, 08:40 AM
I am looking for a macro that delete a row if cell in column B is empty.
Thank you.

GTO
02-07-2014, 04:17 AM
Greetings KillBill,

I see that you just joined vbaexpress :-) Welcome here!

For your current issue, try SpecialCells...


Option Explicit

Sub exampple()

Me.Range("B:B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete

End Sub

PLease note that I used code within the Worksheet's module; thus - the Me keyword. Presuming your code is within a Standard Module, you will want to set an explicit reference to the range differently. As long as the sheet is going to remain in existence, I would suggest the sheet's CodeName.

Hope that helps,

Mark