Do Until Sheets("Sheet1").Cells(x, y).Value = stringOne Or ""
x = x + 1
Loop
In the above VBA code slice, I get a Run-time error '13': Type mismatch. stringOne is declared a String. I can eliminate Or "" and the loop works. I can eliminate stringOne and only have "" and the loop works. Only when I add the Or "" does the loop stop functioning. I've even swapped order, i.e, = "" Or stringOne. Any thoughts?
Any condition needs expressions and operators.
Do until exp1 op exp2 OR exp3
might only be valid if exp3
is a boolean type. "" (String) is not.
So it should be like
Do Until Sheets("Sheet1").Cells(x, y).Value = stringOne Or Sheets("Sheet1").Cells(x, y).Value = ""
You need a boolean operation after the OR, so you basically need:
Do Until Sheets("Sheet1").Cells(x, y).Value = stringOne Or Sheets("Sheet1").Cells(x, y).Value = ""
x = x + 1
Loop
Or "" is not a boolean operation, and therefore you have
Do Until (boolean operation) OR (string constant)
instead of Do Until (boolean operation) OR (boolean operation)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With