I'm referencing a code that was posted here: https://www.mrexcel.com/forum/excel...lete-blank-rows-formula-but-has-no-value.html
This code doesn't appear to run properly if the first row is blank. I think it has something to do with UsedRange. Can someone please tell me where I can address this in the code?
Thank you!
Code:
Sub deleteBlankRows()
Dim lastRow As Long, lastCol As Long, i As Long, myBlanks As Long
With Sheets("Sheet1")
lastRow = .UsedRange.Rows(.Rows.Count).End(xlUp).Row
lastCol = .UsedRange.Columns(.Columns.Count).End(xlToLeft).Column
For i = lastRow To 2 Step -1
myBlanks = Application.WorksheetFunction.CountBlank(.Range(.Cells(i, 1), .Cells(i, lastCol)))
If myBlanks = lastCol Then
.Rows(i).Delete
End If
Next i
End With
End Sub
This code doesn't appear to run properly if the first row is blank. I think it has something to do with UsedRange. Can someone please tell me where I can address this in the code?
Thank you!