I have this Do While loop:
Sub TEST_LOOP()
Dim i As Integer
i = 2
Do While Cells(i, 3) <> "" And _
Int(Mid(Cells(i, 3), 12, 2)) = 21
Value = Value + Cells(i, 4)
i = i + 1
Loop
End Sub
Which is applied to this basic data set:
I get an error message:
"Run-time error '13': Type mismatch.
The problem happens because when the loop reaches the first empty cell (i = 7
)
then the Int function is applied to an empty value Mid(Cells(i, 3), 12, 2
gives nothing). So I was wondering whether there was an efficient way to exit the loop once the cell in question does not meet the two conditions, that is it is not empty and it involves the hour 21.