All i am trying to get is the count right before an empty cell in the following code:
Dim l As Long
Dim r As Long
For l = 0 To 65866
If IsEmpty(wb.Worksheets("Fund Position(URIL)").Range("A1")) Then
Exit For
Else
r = r + 1
End If
Next l
MsgBox r
The above code throws me an Automation error
with a Runtime error : -2147221080 (800401a8)
when it executes the if
statement.
Please help!
Update:
I changed
If IsEmpty(wb.Worksheets("Fund Position(URIL)").Range("A1")) Then
to:
If IsEmpty(wb.Sheets("Fund Position(URIL)").Range("A1")) Then
and it worked. Could someone explain me why is that?