Hi,
I'm trying to remove empty lines in my table so that nothing is left blank in the report. My table is outlined, but the cells are blank. I've tried a different code, but it only allows me to remove lines that aren't outlined.
I need to do this within a range on my sheet. Namely: A24:I26, A28:I33, A38:42. I also want to have this activated as soon as the workbook is open.
I've currently got the code as listed below and it doesn't work, nor does it work for deleting just the range expressed (I'm guessing because the cells aren't populated, but the row isn't exactly blank as it has been outlined within the table)
What am I doing wrong??
NB: When I say Blank lines - I mean the cells in the columns A - I aren't populated with data.
Private Sub Workbook_Open()
Run "delblankrows"
End Sub
Option Explicit
Sub delblankrows()
Dim rngToCheck As Range, rowToCheck As Range
Dim iRow As Integer
Set rngToCheck = ActiveSheet.Range("A24:I32")
For iRow = rngToCheck.rows.Count To 1 Step -1
Set rowToCheck = rngToCheck.rows(iRow)
If Application.CountA(rowToCheck) = "" Then
rowToCheck.EntireRow.Delete
End If
Next iRow
End Sub
Bookmarks