Public WithEvents bt As MSForms.Label
Dim cl(1 To 56) As New palette
Public couleur
Public Function chooseColor()
With palette: .Show: chooseColor = couleur: Unload palette: End With
End Function
Private Sub bt_Click(): palette.couleur = bt.BackColor: palette.Hide: End Sub
Private Sub UserForm_Activate()
Dim I&, T&, A&, obj
For I = 1 To 56
Set obj = Me.Controls.Add("forms.Label.1", "c" & I)
With obj
A = A + 1: .Left = l: .Top = T: .Width = 15: .BackColor = ThisWorkbook.Colors(I)
l = l + 15: If A = 8 Then A = 0: l = 0: T = T + 15
Set cl(I).bt = obj
End With
Next
With Me
.Width = Me.Controls("c" & 56).Left + 20
.Height = Me.Controls("c" & 56).Top + 20
End With
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then couleur = False: Cancel = True: Me.Hide
End Sub