0

I have a big range of cells on 'Sheet 1' A column that I have conditionally formatted. I want to put the RGB color code (if possible in format RRR, GGG, BBB) next to the A column.

Say for example if the conditionally formatted cell has yellow color in any of the cell in A column I need to get the RGB code next to the A column.

enter image description here

Sub Get_RGB_Color_Of_Cell()

    Dim cColor, cRed, cGreen, cBlue
    Dim i, j, x As Integer
    
    j = 2    
    i = 2
    x = 1
    
    Do While Range("A" & j) <> ""
        ActiveSheet.Cells(i, x).Select
        cColor = ActiveSheet.Cells(i, x).Interior.Color
        cRed = (cColor Mod 256)
        cGreen = (cColor \ 256) Mod 256
        cBlue = (cColor \ 65536) Mod 256
        MsgBox (cRed & " " & cGreen & " " & cBlue)

        j = j + 1
        i = i + 1    
    Loop

End Sub

This is not the complete code I was failed to get the color of the Formatted cell it shows in the message box as 255 255 255 for all differently formatted cells with different color.

Thanks in advance..

Tim Williams
  • 154,628
  • 8
  • 97
  • 125
  • 1
    `.DisplayFormat.Interior.Color` – BigBen Apr 04 '23 at 13:55
  • ```Interior.Color``` gives the fixed (unconditional) color, that's why it's white (255,255,255) for all cells. The ```DisplayFormat``` from @BigBen returns the conditional format. – RichardCook Apr 04 '23 at 14:02

0 Answers0