rick051112
New Member
- Joined
- Aug 14, 2023
- Messages
- 3
- Office Version
- 2016
Here is my code:
Sub number()
Dim x as Integer
Do While Cells(x,3) <> 4 Or Cells(x,3).Cells.Offset(0,1) <> 4
x= x + 1
Loop
End Sub
My data is as follow:
C2= 3 D2= 4
C3= 4 C3= 3
C4= 4 D4 = 4
This is a simple example, but I am wondering why "Or" works in the while loop instead of using "And"? Basically the Or statement will take the while loop to the last row, but the And statement stops at the first row.
Thanks!!
Sub number()
Dim x as Integer
Do While Cells(x,3) <> 4 Or Cells(x,3).Cells.Offset(0,1) <> 4
x= x + 1
Loop
End Sub
My data is as follow:
C2= 3 D2= 4
C3= 4 C3= 3
C4= 4 D4 = 4
This is a simple example, but I am wondering why "Or" works in the while loop instead of using "And"? Basically the Or statement will take the while loop to the last row, but the And statement stops at the first row.
Thanks!!