VBA error in for - next loop
Hi there
A few weeks ago I finished adjusting a code I had created in Excel to work with my Zoho Sheets file.
I was very happy with the result, as far as I know you are the only online application that supports Excel VBA.
When I opened the file today, after several weeks of inactivity, it returned an error in one macro which had not posed any problems when I worked with the file the last time.
Anywho, here's the code that returns an error:
- Sub ClearEmpty()
- For k = 1 to 15
- Worksheets(k).UsedRange.Select
- For i = Selection.Rows.Count To 1 Step -1
- If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
- Selection.Rows(i).EntireRow.Delete
- End If
- Next i
- Next k
-
- End Sub
And this is the error message I get: "Encountered error at line 11 :Application defined error"
Basically what this macro does is scroll through the first 15 sheets and deletes any empty rows.