Answers for "excel vba while... "end while" doesn't work?"

VBA
2

excel vba while... "end while" doesn't work?

'In VBA, there is no 'While... End While' loop.

'Attempting to use the above construct will result in a compile-time
'error.

'But VBA does have two loops that use the keyword, 'While'...

While c < 100
	c = c + 1
	'But VBA does not have an 'Exit While' statement.
Wend

Do While c < 100
	c = c + 1
	If c = 75 Then Exit Do
Loop


'The 'Do Loop' can also be written as:      
Do 
	c = c + 1
	If c = 75 Then Exit Do
Loop While c < 100
            
'--------------------------------------------------------------------
            
'The loops can also run backward...
            
c = 99
While c
    'Do something with c here
	c = c - 1
Wend           

c = 99
Do 
    'Do something with c here
	c = c - 1
Loop While c
Posted by: Guest on March-31-2020

Code answers related to "excel vba while... "end while" doesn't work?"

Code answers related to "VBA"

Browse Popular Code Answers by Language