XL 2019 Macro pour plusieurs feuilles

Peychris

XLDnaute Nouveau
Bonjour, débutant en macro; j'ai réussi la macro suivante qui marche pour une feuille. Ayant d'autres feuilles similaire, j'ai reproduit pour chaque feuille cette macro en modifiant uniquement le nom de la feuille pour que çà marche.
J'aimerais si possible faire une seule macro qui marche pour toutes mes feuilles excepté une feuille de mon fichier.
Merci de me venir en aide.
Ci-joint ma macro (en PJ également)
Sub Colorisertableau()

Application.ScreenUpdating = False

Set F1 = Worksheets("202")

With F1
Set Plage = .Range("C3:G20")

End With

For Z = 22 To 31 Step 1

For Each cell In Plage

cell.Select
If cell.Value = Cells(Z, 1).Value Then Selection.Interior.Color = F1.Cells(Z, 1).Interior.Color
If cell.Value = Cells(Z, 1).Value Then Selection.Font.Color = F1.Cells(Z, 1).Font.Color

Next


Next Z

Application.ScreenUpdating = True


End Sub
 

Pièces jointes

  • Planning-Ateliers-LP -.xlsm
    117 KB · Affichages: 11
Solution
Bonjour peychris, le forum

à tester ! et il ne peut y avoir qu'une seule macro avec ce nom "colorisertableau" tu as laissé le même nom pour toutes tes macros, pas bon, il doit y avoir unicité du nom pour une sub.

Bien cordialement, @+
VB:
Sub Coloriser_tableaux()
    Application.ScreenUpdating = False
    Dim F1 As Worksheet, Cell As Range
    For Each F1 In ThisWorkbook.Worksheets
        With F1
            If Not .Name = "General" Then
                Set Plage = .Range("C3:G20")
                For Z = 22 To 31 Step 1
                    For Each Cell In Plage
                        If Cell.Value = Cells(Z, 1).Value Then
                            Cell.Interior.Color = .Cells(Z, 1).Interior.Color...

Bernard_XLD

XLDnaute Barbatruc
Membre du Staff
Bonjour peychris, le forum

à tester ! et il ne peut y avoir qu'une seule macro avec ce nom "colorisertableau" tu as laissé le même nom pour toutes tes macros, pas bon, il doit y avoir unicité du nom pour une sub.

Bien cordialement, @+
VB:
Sub Coloriser_tableaux()
    Application.ScreenUpdating = False
    Dim F1 As Worksheet, Cell As Range
    For Each F1 In ThisWorkbook.Worksheets
        With F1
            If Not .Name = "General" Then
                Set Plage = .Range("C3:G20")
                For Z = 22 To 31 Step 1
                    For Each Cell In Plage
                        If Cell.Value = Cells(Z, 1).Value Then
                            Cell.Interior.Color = .Cells(Z, 1).Interior.Color
                            Cell.Font.Color = .Cells(Z, 1).Font.Color
                        End If
                    Next
                Next Z
            End If
        End With
    Next F1
    Application.ScreenUpdating = True
End Sub
 
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
312 190
Messages
2 086 040
Membres
103 105
dernier inscrit
fofana