I am using excel 2010. I am trying to find the first worksheet with an empty "A1" cell. This workbook is very big and everything works with no errors until iteration 203, where I get "Error 9: Subscript out of range". I do not understand why this happens. My code should find the first empty "A1" cell on worksheet 220, so it is odd that I get the error on worksheet 203. Cell "A1" in worksheet 203 is not different than the "A1" cells of the worksheets preceding it. A portion of my code is attached below.
Public Sub CommandButton1_Click()
Dim firstCell As String
Dim i As Integer
i = 1
firstCell = ThisWorkbook.Sheets(i).Cells(1, 1)
Do Until firstCell = "" Or i = 300
i = i + 1
firstCell = ThisWorkbook.Sheets(i).Cells(1, 1)
Loop
end sub