Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert RGB to Red/Green/Blue component
I've seen this somewhere, but can't find it now. Can someone direct me to
the formulas to convert to R/G/B components. Thanks, Barb Reinhardt |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert RGB to Red/Green/Blue component
Barb,
You can adapt the following code: Dim R As Long Dim G As Long Dim B As Long Dim RGBLong As Long R = &H10 G = &H20 B = &H30 RGBLong = RGB(R, G, B) Debug.Print Hex(RGBLong) R = RGBLong And &HFF G = (RGBLong And &HFF00&) \ &H100& B = (RGBLong And &HFF0000) \ &H10000 Debug.Print Hex(R), Hex(G), Hex(B) Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Mon, 6 Apr 2009 08:04:15 -0700, Barb Reinhardt wrote: I've seen this somewhere, but can't find it now. Can someone direct me to the formulas to convert to R/G/B components. Thanks, Barb Reinhardt |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert RGB to Red/Green/Blue component
Here's one version:
Public Function LongToRGB(theColor As Long, iRed As Integer, iGreen As Integer, iBlue As Integer) As Boolean ' Dim lColor As Long lColor = theColor 'work long iRed = lColor Mod 256 'get red component iGreen = (lColor \ 256) Mod 256 'get green component iBlue = (lColor \ 256 \ 256) Mod 256 'get blue component ' LongToRGB = True End Function HTH, Eric "Barb Reinhardt" wrote: I've seen this somewhere, but can't find it now. Can someone direct me to the formulas to convert to R/G/B components. Thanks, Barb Reinhardt |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert RGB to Red/Green/Blue component
Here is one more method...
Dim Red As Long Dim Green As Long Dim Blue As Long Dim HexVal As String HexVal = Hex(rgbValue) Red = CLng("&H" & Right(HexVal, 2)) Green = CLng("&H" & Mid(HexVal, 3, 2)) Blue = CLng("&H" & Left(HexVal, 2)) Debug.Print Red, Green, Blue -- Rick (MVP - Excel) "Barb Reinhardt" wrote in message ... I've seen this somewhere, but can't find it now. Can someone direct me to the formulas to convert to R/G/B components. Thanks, Barb Reinhardt |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert RGB to Red/Green/Blue component
Note that when using HEX values that Microsoft handles the HEX values in
reverse order. All others (HTML, VB RGB Functions, etc.) = R,G,B Microsoft Hex value is --- B,G,R "Barb Reinhardt" wrote in message ... I've seen this somewhere, but can't find it now. Can someone direct me to the formulas to convert to R/G/B components. Thanks, Barb Reinhardt |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I need to understand yellow input, green is calc, what is blue? | Excel Discussion (Misc queries) | |||
How to replace the background color of all cells from light green to light blue? | Excel Programming | |||
How to replace the background color of all cells from light green to light blue? | Excel Discussion (Misc queries) | |||
Blue to Green and Back to Green | Excel Discussion (Misc queries) | |||
The Excel 2007 Office Convert function sometimes gives me blue scr | Excel Programming |