As a companion to that function (very useful btw, thanks)
This one converts a VBA colour code to a six character hex code useable in CSS etc. Not sure if the blue and green are wrongly labelled, but the order is correct (it produces the right colour). The Hex function returns "0" rather than "00" so it needs padding.
Code:
Private Function fcnLongToHex(ByRef lngColor As Long) As String
Dim hRed, hGreen, hBlue
hRed = Hex(lngColor Mod 256)
If Len(hRed) = 1 Then hRed = "0" & hRed
hGreen = Hex((lngColor \ 256) Mod 256)
If Len(hGreen) = 1 Then hGreen = "0" & hGreen
hBlue = Hex((lngColor \ 256 \ 256) Mod 256)
If Len(hBlue) = 1 Then hBlue = "0" & hBlue
fcnLongToHex = hRed & hBlue & hGreen
End Function