XL 2016 Colorée une cellule identique dans une autre feuille

robertduval

XLDnaute Junior
Bonjour je souhaite pouvoir colorée les mêmes cellules colorées sur une autre feuille, Merci de votre aide
 

Pièces jointes

  • TEST.xlsx
    14.1 KB · Affichages: 7
Solution
Bonjour robertduval, le forum,

Voyez ce fichier (2) et la macro complétée :
VB:
Set r = [D:D,J:J,P:P,V:V,AB:AB]
r.Interior.ColorIndex = xlNone 'RAZ
For Each r In Intersect(r, UsedRange.EntireRow)
    x = CStr(r)
    If d.exists(x) Then r.Interior.Color = d(x)
Next
A+

Lolote83

XLDnaute Barbatruc
Bonjour RobertDuval,
Avec cette petite macro, cela devrait correspondre à tes attentes
VB:
Sub TEST()
    Application.ScreenUpdating = False
    With Sheets("Feuil2")
        .Range("D2:D30").Interior.Color = RGB(255, 255, 255)
    End With
    For Each xCell In Range("C2:C30")
        xEquiv = Application.Match(xCell.Value, Sheets("Feuil2").Range("D2:D30"), 0)
        If IsError(xEquiv) = False Then
            If xCell.Interior.Color = RGB(0, 176, 80) Then
                With Sheets("Feuil2")
                    .Range("D" & xEquiv + 1).Interior.Color = RGB(0, 176, 80)
                End With
            End If
        End If
    Next xCell
    Application.ScreenUpdating = True
    MsgBox "Mise à jour terminée", vbInformation, "MAJ"
End Sub
@+ Lolote83
 

job75

XLDnaute Barbatruc
Bonjour à tous,

Voyez cette macro évènementielle dans le code de Feuil2 :
VB:
Private Sub Worksheet_Activate()
Dim d As Object, c As Range, x$
Set d = CreateObject("Scripting.Dictionary")
d.CompareMode = vbTextCompare 'la casse est ignorée
With Feuil1 'CodeName de la feuille
    If .FilterMode Then .ShowAllData 'si la feuille est filtrée
    For Each c In .Range("C1", .Range("C" & .Rows.Count).End(xlUp))
        x = CStr(c)
        If x <> "" Then d(x) = c.Interior.Color 'mémorise la couleur
    Next
End With
Application.ScreenUpdating = False
If FilterMode Then ShowAllData 'si la feuille est filtrée
[D:D].Interior.ColorIndex = xlNone 'RAZ
For Each c In Range("D1", Range("D" & Rows.Count).End(xlUp))
    x = CStr(c)
    If d.exists(x) Then c.Interior.Color = d(x)
Next
End Sub
Elle se déclenche quand on active la feuille.

A+
 

Pièces jointes

  • TEST(1).xlsm
    21.9 KB · Affichages: 3

job75

XLDnaute Barbatruc
Bonjour robertduval, le forum,

Voyez ce fichier (2) et la macro complétée :
VB:
Set r = [D:D,J:J,P:P,V:V,AB:AB]
r.Interior.ColorIndex = xlNone 'RAZ
For Each r In Intersect(r, UsedRange.EntireRow)
    x = CStr(r)
    If d.exists(x) Then r.Interior.Color = d(x)
Next
A+
 

Pièces jointes

  • TEST(2).xlsm
    23.3 KB · Affichages: 3

Discussions similaires

Statistiques des forums

Discussions
312 102
Messages
2 085 302
Membres
102 857
dernier inscrit
Nony1931