Bonjour,
J'ai une macro qui me crée des boutons automatiquement.
M'aintenant j'aimerais bien que ces bouton lance une macro quand je clique dessus.
Ma question : Comment implémenter la deuxiéme macro avec le click ?
Private Sub UserForm_Initialize()
Z = 1
a = 1
b = 1
For i = 1 To 300
'on prend les champs matos non rentré pour le nivellement => 1
If Sheets("MAT").Cells(i, 6).Value = login.Label3 And Sheets("MAT").Cells(i, 5).Value = "" Then
'on compte le nombre de ligne,
Z = Z + 1
Set CkB = Controls.Add("forms.Checkbox.1")
CkB.Left = 10
CkB.Top = 30 * Z
CkB.Name = b
CkB.Caption = Sheets("MAT").Cells(i, 7)
a = a + 1
For j = 1 To 10
If Sheets("MAT").Cells(i, j + 7) <> "" Then
Set CkB = Controls.Add("forms.Checkbox.1")
CkB.Left = 90 * j + 1
CkB.Top = 30 * Z
CkB.Caption = Sheets("MAT").Cells(i, j + 7)
CkB.Name = a
a = a + 1
End If
Next j
Set bt = Controls.Add("forms.CommandButton.1")
bt.Left = 500
bt.Top = 30 * Z
bt.Name = "cb" & b
bt.Caption = "Validé"
' on nomme les CkB et BT
a = a + 1
b = b + 1
End If
Next i
'on parametre la taille de l'userform en fonction des lignes
With matos_retour
.Width = 600
.Height = Z * 40
End With
End Sub
Merci d'avance
J'ai une macro qui me crée des boutons automatiquement.
M'aintenant j'aimerais bien que ces bouton lance une macro quand je clique dessus.
Ma question : Comment implémenter la deuxiéme macro avec le click ?
Private Sub UserForm_Initialize()
Z = 1
a = 1
b = 1
For i = 1 To 300
'on prend les champs matos non rentré pour le nivellement => 1
If Sheets("MAT").Cells(i, 6).Value = login.Label3 And Sheets("MAT").Cells(i, 5).Value = "" Then
'on compte le nombre de ligne,
Z = Z + 1
Set CkB = Controls.Add("forms.Checkbox.1")
CkB.Left = 10
CkB.Top = 30 * Z
CkB.Name = b
CkB.Caption = Sheets("MAT").Cells(i, 7)
a = a + 1
For j = 1 To 10
If Sheets("MAT").Cells(i, j + 7) <> "" Then
Set CkB = Controls.Add("forms.Checkbox.1")
CkB.Left = 90 * j + 1
CkB.Top = 30 * Z
CkB.Caption = Sheets("MAT").Cells(i, j + 7)
CkB.Name = a
a = a + 1
End If
Next j
Set bt = Controls.Add("forms.CommandButton.1")
bt.Left = 500
bt.Top = 30 * Z
bt.Name = "cb" & b
bt.Caption = "Validé"
' on nomme les CkB et BT
a = a + 1
b = b + 1
End If
Next i
'on parametre la taille de l'userform en fonction des lignes
With matos_retour
.Width = 600
.Height = Z * 40
End With
End Sub
Merci d'avance