How convert .Color property number to RBG values?
Posted on 2010-09-02
I want to convert the number value of a cell background to RGB values in vba
So i get a color from a certain cell...
myColor = myCell.Interior.Color 'will give me a Long value like 65335
'convert that value to the equivalent values in rgb:
redValue = convertToRGB("red", 65335)
greenValue = convertToRGB("green", 65335)
blueValue = convertToRGB("blue", 65335)
then I can color the next cell using:
myOtherCell.Interior.Color = RBG(redValue, greenValue, blueValue)
Yes, i know that I can use colorIndex, and that I could equate the two color objects just to copy the color from one cell to another, however, that is not the point. I need this for other purposes, so I really need to be able to translate the values.
My question: how would the above example "convertToRGB() function work??
It doesnt have to work like the example above, the important thing is that I want to pass in a Long number representing an RGB value, and instead get the RGB values back.