appliquer formatage sur classeur multifeuille

Soleil11

XLDnaute Occasionnel
Bonjour,

Comment je peux appliquer la marcro ci-dessous automatiquement sur tout mon classeur seulement à partir la feuille 4 à l'infini et les 3 premières feuilles du classeur ne doivent être formatée.

Sub Macro1stepCleaning()

' Keyboard Shortcut: Ctrl+m
'
Rows("1:13").Select
Selection.Delete Shift:=xlUp
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Columns("C:C").EntireColumn.AutoFit
Columns("D:F").Select
Selection.Delete Shift:=xlToLeft
Columns("D:F").EntireColumn.AutoFit
Columns("D:F").EntireColumn.AutoFit
Columns("G:G").EntireColumn.AutoFit
Columns("H:H").EntireColumn.AutoFit
Columns("I:I").EntireColumn.AutoFit
Columns("J:J").EntireColumn.AutoFit
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
Application.CutCopyMode = False
Range("A1:Z65000").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"AA1"), Unique:=True
ActiveWindow.LargeScroll ToRight:=0
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ClearContents
ActiveWindow.SmallScroll ToRight:=5
Range("AA1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Cut
ActiveWindow.LargeScroll ToRight:=-1
Range("A1").Select
ActiveSheet.Paste
End Sub

Merci d'avance.

Soleil11::D
 

Robert

XLDnaute Barbatruc
Repose en paix
Re : appliquer formatage sur classeur multifeuille

Bonjour Soleil, Tryssa, bonjour le forum,

J'ai aussi épuré un peu ta macro (donc à vérifié j'ai peut-être fait des erreurs...) :

Code:
Sub Macro1stepCleaning()
Dim x As Integer 'décalre la variable x
 
' Keyboard Shortcut: Ctrl+m
 
For x = 4 To Sheets.Count 'boucle sur tous les onglets (en partant du 4ème)
    Sheets(x).Activate 'active l'onglet
 
    Rows("1:13").Delete Shift:=xlUp
    Columns("A:A").Delete Shift:=xlToLeft
    Rows("2:2").Delete Shift:=xlUp
    Columns("C:C").EntireColumn.AutoFit
    Columns("D:F").Delete Shift:=xlToLeft
    Columns("D:J").EntireColumn.AutoFit
    Range("A1").CurrentRegion.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    Range("A1:Z65000").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
    "AA1"), Unique:=True
    ActiveWindow.LargeScroll ToRight:=0
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.ClearContents
    ActiveWindow.SmallScroll ToRight:=5
    Range("AA1").CurrentRegion.Cut
    Range("A1").Select
    ActiveSheet.Paste
Next x 'prochain onglet de la boucle
End Sub
 

Soleil11

XLDnaute Occasionnel
Re : appliquer formatage sur classeur multifeuille

Bonjour Tryssa,

Merci beaucoup pour ton aide. Est-ce que cela marche si ma feuille 4 à l'infini ont un noms différent de "feuille4" ou "feuille5" ou etc..

Merci pour ta réponse.

Soleil11:)
 

Discussions similaires

Réponses
2
Affichages
963
Réponses
13
Affichages
2 K

Membres actuellement en ligne

Statistiques des forums

Discussions
312 668
Messages
2 090 739
Membres
104 644
dernier inscrit
MOLOKO67