Set Checkbox.Backcolor with ColorIndex

M

Matthew Benson

Hi, I'm trying to create a dynamic form where I want to put 56
checkboxes, each one with one of the different "Excel colors" that
there are. With that I mean the 56 colors that you can set to for
instance a cell by using Interior.ColorIndex.

My problem is that the BackColor should be a Hex value or the
"&H8000000F" format and I don't really have an idea of how to transfer
the ColorIndex values (1, 2, 3, 4 and so on) into one of these
formats.

Anyone have any idea?
 
F

Franck

Hi,
I did that (not a very casual way but it works)
A Form with 56 button with the Tag parameter set to "ColorButton"
Then in the userform intialize :

ButtonCount = 1
For Each ctl In Me.Controls
If (ctl.Tag = "ColorButton") Then
ctl.BackColor = ThisWorkbook.Colors(ButtonCount)
ButtonCount = ButtonCount + 1
End If
Next

Does it suits your need ?
 
Top