Copier fond de cellule d'une autre feuille

Bonjour,

j'ait un fichier sur lequel je voudrais appliquer un fond de cellule par rapport aux même valeurs d'une autre feuille.

Merci à vous tous

Bonjour

Regardes si cela peut te convenir

Bonjour ,

voici ce j'ai adapté sous forme de macro :

Sub Service_rentrant()

'Nommer plage Heure_rose voiture_R
Sheets("HEURE_ROSE").Select

    Range("B2:B170").Select
     Selection.FormatConditions.Delete
    ActiveWorkbook.Names.Add Name:="voiture_R", RefersToR1C1:= _
        "=OFFSET(HEURE_ROSE!R2C2,,,COUNTA(HEURE_ROSE!C2)-1)"

'
'Formule de mise en forme conditionnelle pour mettre en gris les services rentrant

Sheets("ROSE").Select
    ActiveSheet.Unprotect
    Range("E6:E26").Select
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=(MOD(COLONNE();5)=0)*(NB.SI(voiture_R;INDIRECT(ADRESSE(LIGNE();COLONNE()-3)))>2)"
    Selection.FormatConditions(1).Interior.ColorIndex = 16
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=(MOD(COLONNE();5)=0)*(NB.SI(voiture_R;INDIRECT(ADRESSE(LIGNE();COLONNE()-3)))>1)"
    Selection.FormatConditions(2).Interior.ColorIndex = 15

    Range("J6:J26").Select
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=(MOD(COLONNE();5)=0)*(NB.SI(voiture_R;INDIRECT(ADRESSE(LIGNE();COLONNE()-3)))>2)"
    Selection.FormatConditions(1).Interior.ColorIndex = 16
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=(MOD(COLONNE();5)=0)*(NB.SI(voiture_R;INDIRECT(ADRESSE(LIGNE();COLONNE()-3)))>1)"
    Selection.FormatConditions(2).Interior.ColorIndex = 15

    Range("O6:O26").Select
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=(MOD(COLONNE();5)=0)*(NB.SI(voiture_R;INDIRECT(ADRESSE(LIGNE();COLONNE()-3)))>2)"
    Selection.FormatConditions(1).Interior.ColorIndex = 16
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=(MOD(COLONNE();5)=0)*(NB.SI(voiture_R;INDIRECT(ADRESSE(LIGNE();COLONNE()-3)))>1)"
    Selection.FormatConditions(2).Interior.ColorIndex = 15

    Range("T6:T26").Select
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=(MOD(COLONNE();5)=0)*(NB.SI(voiture_R;INDIRECT(ADRESSE(LIGNE();COLONNE()-3)))>2)"
    Selection.FormatConditions(1).Interior.ColorIndex = 16
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=(MOD(COLONNE();5)=0)*(NB.SI(voiture_R;INDIRECT(ADRESSE(LIGNE();COLONNE()-3)))>1)"
    Selection.FormatConditions(2).Interior.ColorIndex = 15
End Sub

Je ne sais pas si l'on peut réduire les lignes de codes ?

Bonjour

isabellette a écrit :

Je ne sais pas si l'on peut réduire les lignes de codes ?

Bien sur avec un résultat de 0 lignes

Il suffit de modifier le nombre de format conditionnel

Sélectionnes A6:T41

1er format

=(MOD(COLONNE();5)=0)*(NB.SI(Voiture;INDIRECT(ADRESSE(LIGNE();COLONNE()-3)))>2)

Format : Couleur Gris - 50%

2ème format

=(MOD(COLONNE();5)=0)*(NB.SI(Voiture;INDIRECT(ADRESSE(LIGNE();COLONNE()-3)))>1)

Format : Couleur Gris - 25%

Rechercher des sujets similaires à "copier fond feuille"