How do I get the corresponding Hex value of an RGB color in Excel/VBA?

后端 未结 5 1172
野的像风
野的像风 2020-12-09 06:01

I\'m trying to set a public const of a color in my VBA code. Normally, I can use:

Dim BLUE As Long
BLUE = RGB(183, 222, 232)

However, ther

5条回答
  •  旧巷少年郎
    2020-12-09 06:47

    I tested this code, cant realy follow Howard's answer

    Dim rd, gr, bl As Integer
    rd = 183
    gr = 222
    bl = 232
    BLUE = RGB(rd, gr, bl)
    hexclr = Format(CStr(Hex(rd)), "00") +
    Format(CStr(Hex(gr)), "00") + 
    Format(CStr(Hex(bl)), "00")
    MsgBox hexclr 'B7DEE8
    

提交回复
热议问题