I am trying to set an orangish color in the following manner:
WorkSheet.Range(\"A1:A5\").Interior.color = 49407
and
WorkShe
I believe the answers from Gimp and Johannes both miss the key issue.
A colour on a computer screen is defined by specifying how much red, blue and green you require. For each of the three colours you specify a number between 0 and 255. These three numbers are normally specified as a single number by concatenating the three separate numbers. With Html you specify a colour as #RRGGBB where RR, GG and BB are hexadecimal numbers or you can replace RRBBGG by the decimal equivalent. With Excel the sequence is reversed so &HBBGGRR or the decimal equivalent.
49407 is the decimal equivalent of 00C0FF which for Excel means Blue = 0, Green = 192 and Red = 255.
But &HC0FF or &H00C0FF is -16129 or Blue = 255, Green = 192 and Red = 255. This seems to be a flaw in the &H conversion. I cannot find anyway of getting C0FF converted to 49407.
If you insist on using the &H conversion, the best I can offer is:
Range("A1:A5").Interior.color = &H01C0FF
This is Blue = 1, Green = 192 and Red = 255 and I cannot tell the difference from Blue = 0, Green = 192 and Red = 255.
But I would recommend:
Range("A1:A5").Interior.color = RGB(255,192,0)
because the RGB function always returns a positive number and you do not have to worry about Excel's reverse sequence.