Forum Discussion

2 Replies

  • Riny_van_Eekelen's avatar
    Riny_van_Eekelen
    Platinum Contributor

    Rao_Azeem 

    I believe you wish to read out the RGB code for the color of a particular cell. You need user a defined function in VBA to do this. Found the code on-line, here:

    https://excelribbon.tips.net/T010180_Determining_the_RGB_Value_of_a_Color.html

     

    Adopted it a bit so that it gives the output that you desire.

     

     

    Function getRGB(rcell) As String
        Dim C As Long
        Dim R As Long
        Dim G As Long
        Dim B As Long
    
        C = rcell.Interior.Color
        R = C Mod 256
        G = C \ 256 Mod 256
        B = C \ 65536 Mod 256
        getRGB = R & ";" & G & ";" & B
        
    End Function

     

     

      Enter a formula as usual, assuming the coloured cell is A1:

     

     

    =getRGB(A1)

     

     

      

Resources