Dec 04 2019 01:08 AM
Hi,
I want to know how can I get a cell background color code and get this color RGB properties in a cell
Dec 04 2019 03:46 AM - edited Dec 04 2019 03:48 AM
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)
Dec 04 2019 05:43 AM