That 'arbitrary' number is a mathematical combination of the RGB values (B.256^2 + G.256 + R) and a conversion of the hex color value to a decimal number (base 16 to base 10), depending on which way you want to look at it. Just different bases.
Below is the method I use in the XLAM addin file I wrote for Excel. This method has come in handy many times. I have included the documentation in my addin file. Short Answer: There is no built in functionality for this. You must write your own function. Long Answer: The long that is returned from the Interior.Color property is a decimal conversion of the typical hexidecimal numbers that we are used to seeing for colors in html e.g.
Additionally the constant xlNone (-4142) can be passed to set cell to have no color in the background, however such cells are marked white RGB(255, 255, 255) from the Get property. Knowing this, we can write a function that returns one or all of the appropriate RGB values. Luckily, a kind Mr. Allan Wyatt has done just that here! Mark Balhoff´s VBA script works fine. All credits go to him.
Free VBA Course: List of RGB values with the corresponding colors.
A valuable addition sure and I appreciate the citation but a couple quick notes: 1) DisplayFormat call will error if this is used as a Worksheet Function and 2) Changing the second Select Case formatType to Select Case formatType Mod 4 allows the deleting of cases 4 to 7 (unnecessary code duplication). I'd also probably choose to convert the last Case in the big switch block to a Case Else to default on bad user input and convert the smaller switch block to If formatType.
Should note, for the hex values, if you're exporting out to HTML you're going to get quirks too. Ideally you'd create the hex string from the individual colours, rather than returning a hex from the ColorVal number.
The reason being you can get some invalid hex numbers if the cell is a 'pure' colour like green/blue RED - RGB(255,0,0) returns 'FF' - it should return 'FF0000' BLUE - RGB(0,0,255) returns 'FF00000' - it should return '0000FF' If you used these to create HTML/CSS colour output, you'd get RED for any blue cells. I modified the script to assemble each two character hex 'chunk' based on the RGB values, with a UDF that just pads with a leading 0 where output of one character is returned ( hopefully if you're reading this, you can make something similar ) Color = ZeroPad(Hex((colorVal Mod 256)), 2) & ZeroPad(Hex(((colorVal 256) Mod 256)), 2) & ZeroPad(Hex((colorVal 65536)), 2) -Edit: forgot to include the code for the UDF. Function ZeroPad(text As String, Cnt As Integer) As String 'Text is the string to pad 'Cnt is the length to pad to, for example ZeroPad(12,3) would return a string '012', Zeropad(12,8) would return '00000012' etc. Dim StrLen As Integer, StrtString As String, Padded As String, LP As Integer StrLen = Len(Trim(text)) If StrLen.