[FONT=Wingdings][SIZE=3]§[/SIZE] [/FONT][B][FONT=Arial][SIZE=3]Macro 1 : créer les onglets d’un fichier à partir d’un filtre automatique[/SIZE][/FONT][/B]
[FONT=Arial]Sub Créer_objectifs_CC()[/FONT]
[FONT=Arial]Application.ScreenUpdating = False [/FONT][SIZE=2][COLOR=teal][FONT=Arial]'ne pas voir ce qui se passe à l'écran, diminue besoin mémoire[/FONT][/COLOR][/SIZE]
[FONT=Arial]For lgn = 2 To 24 [/FONT][SIZE=2][COLOR=teal][FONT=Arial]'pour boucler sur les lignes 2 à 24[/FONT][/COLOR][/SIZE]
[FONT=Arial]Sheets("Ref").Select [/FONT][SIZE=2][COLOR=teal][FONT=Arial]'on se place sur la feuille de référence[/FONT][/COLOR][/SIZE]
[FONT=Arial]indic = Cells(lgn, 1).Value [/FONT][SIZE=2][COLOR=teal][FONT=Arial]'on variabilise, indic = cellule ligne de la boucle, colonne 1[/FONT][/COLOR][/SIZE]
[FONT=Arial]Sheets("Recap Objectif CC").Select [/FONT][SIZE=2][COLOR=teal][FONT=Arial]''on se place sur la feuille où se trouve la BD[/FONT][/COLOR][/SIZE]
[FONT=Arial]Range("e1").Select [COLOR=teal]'[/COLOR][/FONT][SIZE=2][COLOR=teal][FONT=Arial]on choisit un indicateur dans filtre automatique[/FONT][/COLOR][/SIZE]
[FONT=Arial]Selection.AutoFilter[/FONT]
[FONT=Arial]Selection.AutoFilter Field:=5, Criteria1:=indic [COLOR=green]‘ [/COLOR][/FONT][SIZE=2][COLOR=green][FONT=Arial]l’indicateur[/FONT][/COLOR][COLOR=teal][FONT=Arial] se trouve en colonne 5[/FONT][/COLOR][/SIZE]
[FONT=Arial]Range("A1:R1500").Select[/FONT]
[FONT=Arial] Range("R1500").Activate[/FONT]
[FONT=Arial] Selection.Copy[/FONT]
[FONT=Arial]Sheets.Add After:=Worksheets(Worksheets.Count) [/FONT][COLOR=teal][FONT=Arial][SIZE=2]'on ajoute un onglet après les[/SIZE][/FONT][/COLOR][COLOR=teal][FONT=Arial] 2 [/FONT][/COLOR][SIZE=2][COLOR=teal][FONT=Arial]premières[/FONT][/COLOR][FONT=Arial] [COLOR=green]feuilles[/COLOR][/FONT][/SIZE]
[FONT=Arial]ActiveSheet.Name = indic [/FONT][SIZE=2][COLOR=teal][FONT=Arial]'on nomme l'onglet comme nom indicateur[/FONT][/COLOR][/SIZE]
[FONT=Arial]Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _[/FONT]
[FONT=Arial]False, Transpose:=False [COLOR=teal]' on colle[/COLOR][/FONT]
[FONT=Arial][E9] = "Somme" [/FONT][SIZE=2][FONT=Arial][COLOR=teal]‘facultatif : possibilité de faire total de chaque colonne sur chaque feuille[/COLOR][/FONT][/SIZE]
[FONT=Arial]Range("F9").Select[/FONT]
[FONT=Arial]ActiveCell.FormulaR1C1 = "=IF(COUNT(R[-7]C:R[-2]C)=0,"""",SUM(R[-7]C:R[-2]C))"[/FONT]
[FONT=Arial]Range("F9").Select[/FONT]
[FONT=Arial]Selection.AutoFill Destination:=Range("F9:Q9"), Type:=xlFillDefault[/FONT]
[FONT=Arial]Range("F9:Q9").Select[/FONT]
[FONT=Arial]ActiveWindow.ScrollColumn = 1[/FONT]
[FONT=Arial]Range("E9").Select[/FONT]
[FONT=Arial]Next lgn [/FONT][SIZE=2][COLOR=teal][FONT=Arial]' on continue sur 2nd, 3èm.. [/FONT][/COLOR][COLOR=teal][FONT=Arial]indicateur (boucle)[/FONT][/COLOR][/SIZE]
[FONT=Arial]Application.ScreenUpdating = True[/FONT]
[FONT=Arial]End Sub[/FONT]