rgb

  • Thread starter Thread starter June
  • Start date Start date
J

June

Through VBA how do I get the individual RGB colours for the interior of a
cell?
 
June,

Here is a function, and an example test

Public Function GetRGB(colour As Long, ByRef red, ByRef green, ByRef blue)

red = colour And &HFF
green = colour \ 256 And &HFF
blue = colour \ 256 ^ 2 And &HFF

End Function


Sub test()
Dim vRed, vGreen, vBlue

GetRGB ActiveCell.Interior.Color, vRed, vGreen, vBlue
Debug.Print vRed, vGreen, vBlue

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Thanks Bob

Bob Phillips said:
June,

Here is a function, and an example test

Public Function GetRGB(colour As Long, ByRef red, ByRef green, ByRef blue)

red = colour And &HFF
green = colour \ 256 And &HFF
blue = colour \ 256 ^ 2 And &HFF

End Function


Sub test()
Dim vRed, vGreen, vBlue

GetRGB ActiveCell.Interior.Color, vRed, vGreen, vBlue
Debug.Print vRed, vGreen, vBlue

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top