Bonjour,
je réalise une macro dans un userform. Le clic d'un CommandButton ouvre 3 autres CommandButton.
Les 3 commandButton en question sont créés ainsi :
Public Sub bouton_commune_aep_Click()
Dim Obj1 As Control
Dim Obj2 As Control
Dim Obj3 As Control
Dim Obj4 As Control
Set Obj1 = Me.Controls.Add("forms.OptionButton.1")
With Obj1
.Name = "hbt_300"
.Caption = "< 300"
.Height = 21
.Left = 198
.Top = 130
.Width = 75
End With
Set Obj2 = Me.Controls.Add("forms.OptionButton.1")
With Obj2
.Name = "hbt_moins10000"
.Caption = "< 10000"
.Height = 21
.Left = 198
.Top = 150
.Width = 75
End With
Set Obj3 = Me.Controls.Add("forms.OptionButton.1")
With Obj3
.Name = "hbt_plus10000"
.Caption = "> 10000"
.Height = 21
.Left = 198
.Top = 170
.Width = 75
End With
Set Obj4 = Me.Controls.Add("forms.Label.1")
With Obj4
.Name = "label_hbt_aep"
.Caption = "Nombre d'habitants"
.Height = 21
.Left = 198
.Top = 114
.Width = 150
End With
End Sub
Je souhaiterais que le Clic dans l'un des 3 CommandButton affiche une phrase de réponse dans un Label toujours dans ma UserForm initiale. Je ne parviens pas à trouver la syntaxe ni où la mettre pour réaliser cette condition qui se traduit par :
"Si CommandButton untel est cliqué alors écris cela dans Label truc"
J'ai testé qqchose du style
Private Sub UserForm_Initialize()
If CommandButton_Click = True Then
label.Caption = texte
End If
End Sub
Est-ce compréhensible ?
Merci d'avance
Olivier