- Selva V Pasupathy, HSBC Global Resourcing, Hyderabad
Last week , somebody sent me a mail asking if there is a way to convert decimal values of colors to rgb values. I thought excel solver addin already provides different ways to convert binary, decimal, hex values, so the function to convert decimal values to rgb values should be available in solver. But then I was not able to get function to convert decimal to rgb. I tried some functions in excel and made the function to convert decimal to rgb. I am not too sure if this is absolutely correct; but I have tried this with some of the decimals and I am getting the correct rgb value.
HOW SHOULD I USE THE FOLLOWING CODE
Let me know if you have any comment or feedback on this.
Private Function Convert_Dec2RGB(ByVal myDECIMAL As Long) As String Dim myRED As Long Dim myGREEN As Long Dim myBLUE As Long myRED = myDECIMAL And &HFF myGREEN = (myDECIMAL And &HFF00&) \ 256 myBLUE = myDECIMAL \ 65536 Convert_Dec2RGB = CStr(myRED) & "," & CStr(myGREEN) & "," & CStr(myBLUE) End Sub