Valoute
XLDnaute Nouveau
Bonjour,
j'aimerais savoir s'il est possible d'ajouter un CommandButton dans un Userform à partir d'une macro, créer une position aléatoire puis par la suite l'orienter grâce à "Left" et "Height".
Tout ça à partir d'une boucle.
Ce qui donnerais par exemple:
j'aimerais savoir s'il est possible d'ajouter un CommandButton dans un Userform à partir d'une macro, créer une position aléatoire puis par la suite l'orienter grâce à "Left" et "Height".
Tout ça à partir d'une boucle.
Ce qui donnerais par exemple:
Code:
Dim Nb As Integer
Nb = Worksheets.Cells(2, 3).Value
If Nb <= 3 Then
For i = 1 To Nb
Userformx.CommandButtoni.Create
Userformx.CommandButtoni.Top = 6
Userformx.CommandButtoni.Left = 12 * i * 8
Userformx.CommandButtoni.Height = 42
Next
End If
If Nb <= 6 Then
For i = 1 To 3
Userformx.CommandButtoni.Create
Userformx.CommandButtoni.Top = 6
Userformx.CommandButtoni.Left = 12 * i * 8
Userformx.CommandButtoni.Height = 42
Next
For i = 4 To Nb - 3
Userformx.CommandButtoni.Create
Userformx.CommandButtoni.Top = 6 * i * 3
Userformx.CommandButtoni.Left = 12 * i * 8
Userformx.CommandButtoni.Height = 42
Next
End If
' Etc...
Dernière édition: