I'm trying to run a macro that selects blank cells in a table column and deletes the entire row.
The script below does everything except the deleting part, which prompts the following error:
run-time error 1004 - "Delete method of Range class failed"
I have used the following code:
Sub test()
Range("Table1[[New]]").Activate
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Delete
End Sub
There is also a very handy keyboard shortcut to delete rows (columns or cells). Press Ctrl + – on the keyboard. That's it! Our blank rows are gone now.
To delete multiple contiguous blank rows using a keyboard shortcut: Drag across the row headings using a mouse or select the first row heading and then Shift-click the last row heading. Press Ctrl + – (minus sign at the top right of the keyboard) to delete the selected rows.
This One liner also would help
on error resume next 'to continue macro if no empty row is found in table .Range("Table1").Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
'this delete empty using 1st column as reference for checking blanks 'Use custom names for tables for easy manipulation in codes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With