Q:

vba do while

' OPTION 1
i =0
Do While i < 3 'Check Condition at the START of the loop
  ' Do something
  i = i + 1
Loop 

'OPTION 2
i =0
Do
  ' Do something
  i = i + 1
Loop While i < 3 'Check Condition at the END of the loop
0
Sub combineNamesWhile()
 i = 2
 Do While Not IsEmpty(Cells(i, 1)) OR Not IsEmpty(Cells(i, 2))
   If IsEmpty(Cells(i, 1)) Then
     Cells(i, 3).Value = Cells(i, 2)
   ElseIf IsEmpty(Cells(i, 2)) Then
     Cells(i, 3).Value = Cells(i, 1)
   Else
     Cells(i, 3).Value = Cells(i, 1) & " " & Cells(i, 2)
   EndIf
   i = i +1
   Loop
End Sub
0
Not IsEmpty(Cells(i, 1)) OR Not IsEmpty(Cells(i, 2))
0

New to Communities?

Join the community