Excel - Power Query - Power Pivot - VBA
Share
Explore
Visual Basic

icon picker
Boucles

For ... Next

Visual Basic propose différentes boucle, nous montrons ici la plus utilise dans Excel :
For compteur = debut To Fin Step Pas
instructions
Exit For
Next
Exemple :
For i = 1 to 10
Debug.Print i
Next

For Each ... Next

For Each objet In collection d'objets
instructions
Exit For
Next
Par exemple, les instructions suivantes renomment chaque feuille du classeur actif, en les nommant “Feuille 1”, “Feuille 2”, etc.
Dim ws As WorkSheet
Dim a
For Each ws In ActiveWorkbook.Worksheets
ws.name = "Feuille " & a
a = a + 1
Exit For
Next

Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.