Hello I am trying to get the VBA code to delete a row if there is no data in a cell in that row. for example if D5 is blank delete row 5.
I can get the Code to do this function row by row but I dont want to write it out 5000 times. Is there a formula to say repete function between rows 18-5000
Hi GrahamRoss, this one liner should do it (for the full column). If you want to do it for specific rows, just change D:D to something like D18:D5000.
Hope that helps!Sub delrows() Range("D:D").SpecialCells(xlCellTypeBlanks).EntireRow.Delete End Sub
Can I add that to the botom of another sub routine it seems to just do the first one and then stop and not go onto delete the rows
You can certainly add it to the bottom of the first macro, or put it in a standard module and call it from the first macro. (e.g. "Call delrows")
If the first macro is an event macro (Worksheet_Change, etc.) you may want to disable events at the beginning of the macro and then re-enable at the end so your change event isn't re-triggered.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks