Quick way without bitmasks, this returns a 3 element array the first element
is the red value the second is the green and the third is the blue.
Function RevRGB(RGBIn As Long) As Variant
Dim strHex As String
Dim intRed As Integer
Dim intGreen As Integer
Dim intBlue As Integer
Const PAD_ZERO = "000000"
strHex = Right(PAD_ZERO & Hex(RGBIn), 6)
intBlue = Val("&H" & Mid(strHex, 1, 2))
intGreen = Val("&H" & Mid(strHex, 3, 2))
intRed = Val("&H" & Mid(strHex, 5, 2))
RevRGB = Array(intRed, intGreen, intBlue)
End Function
sample call
Sub TestRevRGB()
Dim varRet As Variant
Dim lngColor As Long
lngColor = RGB(255, 254, 253)
varRet = RevRGB(lngColor)
Debug.Print lngColor; "= "; varRet(0), varRet(1), varRet(2)
lngColor = RGB(0, 1, 2)
varRet = RevRGB(lngColor)
Debug.Print lngColor; "= "; varRet(0), varRet(1), varRet(2)
End Sub