Loops in VBA

There are situations when you want to execute a block of code multiple number of times. In general, statements are executed sequentially, The first statement in a function is executed first, followed by the second, and so on.




there are multiple types of loops in visual basic , to handle all kind of looping situations

1.  for loop - Executes a sequence of statements multiple times and     reduces the code that manages the loop variable.
2.  for each loop - This is executed if there is at least one element   in the group and repeated for each element in a variable.
3.  while loop - This check the condition before executing the loop   body
4.  do while loops - The do While statements will be executed as long   as the condition is True. The Loop will be repeated untill the   condition become False.
5.  do until loops - The do Until statements will be executed as long   as the condition is False. The Loop should be repeated till the   condition is True.
  

Post a Comment

0 Comments