1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Sub ajout()
Dim x As Variant
Dim y, w, z As Variant
Dim ligne
x = Range("C1").Value 'x = nom du secteur1
y = Range("C3").Value 'y = nom du secteur2
ligne = 1
If Cells(ligne, 3) = x Then
Workbooks.Add
Do While Cells(ligne, 3) = x 'la cellule en colonne 3 contient le nom du secteur 1
w = Cells(ligne, 1).Value
Sheets.Add 'alors tu crée un onglet
ActiveSheet.Name = w 'tu nomme l'onglet par le contenu de la colonne 1
ligne = ligne + 1
Loop
End If
If Cells(ligne, 3) = y Then
Workbooks.Add
Do While Cells(ligne, 3) = y
z = Cells(ligne, 1).Value
Sheets.Add
ActiveSheet.Name = z
ligne = ligne + 1
Loop
End If
End Sub |