VBA Do Until Loop with Or "" condition

conditional-statements, excel, loops, vba

Solution

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 = ""

Problem

``` 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?

Original source