Hi,
I'm getting an error 9 (subscript out of range) when running the script below:
[vba]Public Sub RemoveEmptyRows()
Dim c As Range
Dim i As Long
Dim arr(1, 3)
arr(0, 0) = "Sheet1"
arr(1, 0) = "A1:A105"
arr(0, 1) = "Sheet2"
arr(1, 1) = "A1:A100"
arr(0, 2) = "Sheet3"
arr(1, 2) = "A1:A95"
arr(0, 3) = "Sheet4"
arr(1, 3) = "A1:A90"
For i = 0 To 3
For Each c In Sheets(arr(0, i)).Range(arr(1, i))
If c = "" Then c.ClearContents
Next c
Sheets(arr(0, i)).Range(arr(1, i)).SpecialCells(xlCellTypeBlanks).EntireRow.EntireRow.Delete
Next
End Sub [/vba]
The error occurs on the following line:
[vba]For Each c In Sheets(arr(0, i)).Range(arr(1, i))[/vba]
The script: step 1) remove formula from empty cell withing range, step 2) delete entire row if first cell is empty
It works for the first 3 sheets, not for the last.
Any ideas why I'm getting an error 9?
Thanks in advance.