I think I need a loop function for this but i’m not sure how to go about it.
The task for this is to see if a specific column is blank, then to delete that row. But sometimes there is no blank cells and i am getting a end debug error.
Here is my code:
Sub DeleteRow()
Dim lr As Long
Dim shCurrentWeek As Worksheet
Set shCurrentWeek = AciveWorkbook.Sheets("Current Week")
lr = shCurrentWeek.Range("A" & Rows.Count).End(xlUp).Row
'Delete Row
shCurrentWeek.Range("B4:B" & lr).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
any ideas?
While Daniel Cook is right, you could use
On Error Resume Next, here is another way of going about it, since usingOn Error Resume Nextis really a last resort option in VBA (IMO).The code below checks for blanks before it tries to use the
SpecialCellsmethod.