C'est ça ton explication???
Bonjour à tous
Je suis novice en macrologie
Je récupère un classeur dont je ne suis ni le créateur ni le propriétaire. Ce classeur est alimenté par une quinzaine de personnes
Ce classeur contient plusieurs feuilles dont "lundi" "mardi" "mercredi" "jeudi" "vendredi" "samedi" "dimanche"
Chaque jour j'ai besoin de filtrer trois colonnes parmi onze colonnes existantes. Ensuite je les trie du plus petit au plus grand dans la colonne A. Enfin, je mets les doublons en surbrillance selon la colonne A
Ne maitrisant pas VBA j'ai utilisé l'enregistreur de macro. Je l'ai utilisé depuis la feuille appelée "Mercredi L1"
Voici mon problème : Si je lance ma macro en commençant par mercredi, puis les autres jours tout se déroule normalement
Si je lance la macro depuis un autre jour elle plante à la ligne ".Apply"
Si je recopie ma macro en remplaçant partout "mercredi L1" par un autre jour de la semaine, je peux la lancer dans la feuille correspondante, mais je ne trouve pas cela très propre... Sauriez-vous m'aider à n'avoir qu'une seule macro qui fonctionne avec toutes les feuilles ?
Ci dessous, la macro créée avec l'enregistreur de macro...
Merci d'avance pour votre aide
Sub Nettoyage_Synthese_Mercredi_L1()
'
' Nettoyage_Synthese Macro_Mercredi_L1
'
Range("A1").Select
Application.ScreenUpdating = False
Cells.Select
Selection.UnMerge
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Cells.Select
Selection.EntireColumn.Hidden = False
Range("A:A,C:C,E:E,F:F,G:G,H:H,I:I,K:K,L:L,M:M,N:N,O:O,P
😛,Q:Q,R:R,S:S,T:T"). _
Select
Range("T1").Activate
Selection.Delete Shift:=xlToLeft
Columns("A:A").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$A$414").AutoFilter Field:=1, Criteria1:="=Poste", _
Operator:=xlOr, Criteria2:="="
ActiveWindow.SmallScroll Down:=223
Cells.Select
Selection.Delete Shift:=xlUp
ActiveWorkbook.Worksheets("Mercredi L1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Mercredi L1").Sort.SortFields.Add2 Key:=Range( _
"A1:A414"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Mercredi L1").Sort
.SetRange Range("A1:U414")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Columns("A:A").Select
Selection.FormatConditions.AddUniqueValues
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).DupeUnique = xlDuplicate
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Columns("C:C").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="=29"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("A1").Select
Dim s As Shape
For Each s In ActiveSheet.Shapes
s.Delete
Next
Application.ScreenUpdating = True
End Sub