Remplir un comboBox2 d'un Userfom2 a partir d'un comboBox1 d'un UserForm1
Bonjour,
Je voudrais que vous m'aider sur un problème de VBA Excel
Je veux remplir automatiquement le comboBox2 qui se trouve sur mon UserForm2 a partir du comboBox1 trouvant sur mon UserForm1.
Exemple si j'ai A dans mon comboBox1 du UserForm1 sa doit apparaitre automatiquement sur mon comboBox2 du UserForm2.
Merci
Bien cordialement
Alioune SENE
Bonjour
Dans ton userform2, tu mets cet évènement, si c'est bien cela que tu veux:
Private Sub UserForm_Initialize()
ComboBox2.List = UserForm1.ComboBox1.List
End SubDis-moi
A+
Je suis désolé Patty5046 mais sa ne marche pas
Maintenant, Voici le code mon UserForm3
Private Sub ComboBox5deux_Change()
End Sub
'********************************************************************************************************************
'PROCEDURE PERMETTANT D'ACTVER/DESACTIVER LE CheckBox1deux ET DE REMPLIR LE ComboBox1trois A L'AIDE DU CheckBox1deux
'********************************************************************************************************************
Private Sub CheckBox1deux_Click()
If CheckBox1deux.Value = True Then 'Si CheckBox1deux = Vrai
ComboBox1trois.AddItem CheckBox1deux.Caption 'Mettez la valeur du CheckBox1deux dans le ComboBox1trois
Else 'Sinon
ComboBox1trois.Clear 'Supprimer la valeur du ComboBox1trois
CheckBox1deux.Value = False 'CheckBox1deux = Faux
CheckBox2deux.Value = False
CheckBox3deux.Value = False
CheckBox4deux.Value = False
End If
End Sub
'********************************************************************************************************************
'PROCEDURE PERMETTANT D'ACTVER/DESACTIVER LE CheckBox2deux ET DE REMPLIR LE ComboBox1trois A L'AIDE DU CheckBox2deux
'********************************************************************************************************************
Private Sub CheckBox2deux_Click()
If CheckBox2deux.Value = True Then
ComboBox1trois.AddItem CheckBox2deux.Caption
Else
ComboBox1trois.Clear
CheckBox1deux.Value = False
CheckBox2deux.Value = False
CheckBox3deux.Value = False
CheckBox4deux.Value = False
End If
End Sub
Private Sub CheckBox3deux_Click()
If CheckBox3deux.Value = True Then
ComboBox1trois.AddItem CheckBox3deux.Caption
Else
ComboBox1trois.Clear
CheckBox1deux.Value = False
CheckBox2deux.Value = False
CheckBox3deux.Value = False
CheckBox4deux.Value = False
End If
End Sub
Private Sub CheckBox4deux_Click()
If CheckBox4deux.Value = True Then
ComboBox1trois.AddItem CheckBox4deux.Caption
Else
ComboBox1trois.Clear
CheckBox1deux.Value = False
CheckBox2deux.Value = False
CheckBox3deux.Value = False
CheckBox4deux.Value = False
End If
End Sub
'******************************************************************************
'PROCEDURE PERMETTANT DE REMPLIR LE ComboBox2trois A L'AIDE DU ComboBox1trois
'******************************************************************************
Private Sub ComboBox1trois_Change()
'UserForm10.ComboBox1n = UserForm3.ComboBox1trois.Value 'Mettre automatiquement la valeur de ComboBox1trois dans ComboBox1n
End Sub
Private Sub ComboBox2trois_Change()
End Sub
Private Sub ComboBox3trois_Change()
End Sub
Private Sub CommandButton2trois_Click() 'Bouton precedent
'************************************************************************************************************
'PROCEDURE PERMETTANT DE VIDER TOUTES LES CELLULES DE LA FEUILLE SOURCE APRES CLIK SUR LE BOUTON PRECEDENT
'************************************************************************************************************
ActiveCell.Offset(0, 6).Value = ""
ActiveCell.Offset(0, 7).Value = ""
ActiveCell.Offset(0, 8).Value = ""
ActiveCell.Offset(0, 9).Value = ""
ActiveCell.Offset(0, 10).Value = ""
'**********************************************************************
'PROCEDURE PERMETTANT DE FAIRE LA REDIRECTION VERS LA PAGE PRECEDENTE
'**********************************************************************
UserForm3.Hide 'fermeture le l'interface UserForm2
UserForm2.Show 'Redirection la page vers la feuille excel OBSERVATOIRE
End Sub
Private Sub CommandButton1trois_Click() 'Bouton suivant
'**************************
'DECLARATION DES VARIABLES
'**************************
Dim Prepaye As String
Dim Postpaye As String
Dim a As String
Dim b As String
Dim c As String
Dim d As String
Dim l As String
Dim m As String
'**************************
'AFFECTATION DES VARIABLES
'**************************
a = "Non coche"
b = "Non coche"
c = "Non coche"
d = "Non coche"
l = "Non coche"
m = "Non coche"
'Boutons radio
If OptionButton2.Value = True Then 'Si OptionButton2 = Vrai alors
l = "Coche" 'met cellule Coche
Else 'Sinon
l = "Non coche" 'met cellule Non coche
End If 'Fin du si
If OptionButton1.Value = True Then
m = "Coche"
Else
m = "Non coche"
End If
'***********************************************************************************************
'PROCEDURE PERMETTANT DE COCHER LES CELLULES DANS LE FICHIER EXCEL A L'AIDE DU CheckBox1deux
'***********************************************************************************************
If CheckBox1deux.Value = True Then 'Si CheckBox1deux = Vrai
a = "Coche" 'mettre a = coche
End If
If CheckBox2deux.Value = True Then
b = "Coche"
End If
If CheckBox3deux.Value = True Then
c = "Coche"
End If
If CheckBox4deux.Value = True Then
d = "Coche"
End If
'If IsNumeric(TextBox1trois.Value) <> True Then 'Sinon si textBox1trois numerique est different de vrai
'Beep
'MsgBox "Mois est numerique" 'afficher ce texte ("Mois est numerique" )
If ComboBox3trois = "Postpaye" Then 'Sinon si ComboBox4deux = Non
Beep
MsgBox "STOP INTERVIEW" 'afficher ce message STOP INTERVIEW
ElseIf CheckBox1deux = False And CheckBox2deux = False And CheckBox3deux = False And CheckBox4deux = False Then
Beep
MsgBox "Veuillez remplir tous les champs svp!!!"
ElseIf ComboBox1trois = "" Then
Beep
MsgBox "Veuillez remplir tous les champs svp!!!"
ElseIf OptionButton2 = False And OptionButton1 = False Then
Beep
MsgBox "Veuillez remplir tous les champs svp!!!"
ElseIf ComboBox3trois = "" Then
Beep
MsgBox "Veuillez remplir tous les champs svp!!!"
Else
'****************************************************
'PROCEDURE PERMETTANT DE REMPLIR LA BASE DE DONNEES
'****************************************************
'Sheets("test").Activate 'Fais les instructions ci-dessous
'Range("A1").Select
'Selection.End(xlDown).Select
'Selection.Offset(1, 0).Select
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'ActiveCell.Offset(0, 0).Value = a
'ActiveCell.Offset(0, 1).Value = b
'ActiveCell.Offset(0, 2).Value = c
'ActiveCell.Offset(0, 3).Value = d
'ActiveCell.Offset(0, 4).Value = ComboBox1trois.Value
'ActiveCell.Offset(0, 5).Value = TextBox1trois '.Value
'ActiveCell.Offset(0, 6).Value = l
'ActiveCell.Offset(0, 7).Value = m
'ActiveCell.Offset(0, 8).Value = ComboBox3trois.Value
ActiveCell.Offset(0, 11).Value = a
ActiveCell.Offset(0, 12).Value = b
ActiveCell.Offset(0, 13).Value = c
ActiveCell.Offset(0, 14).Value = d
ActiveCell.Offset(0, 15).Value = ComboBox1trois.Value
ActiveCell.Offset(0, 16).Value = TextBox1trois.Value
ActiveCell.Offset(0, 17).Value = l
ActiveCell.Offset(0, 18).Value = m
ActiveCell.Offset(0, 19).Value = ComboBox3trois.Value
CheckBox1deux.Value = False
CheckBox2deux.Value = False
CheckBox3deux.Value = False
CheckBox4deux.Value = False
'ComboBox1trois = ""
'TextBox1trois = ""
'OptionButton2 = False
'OptionButton1 = False
'ComboBox2trois = ""
'ComboBox3trois = ""
UserForm3.Hide 'fermeture UserForm3
UserForm5.Show 'Afficher UserForm5
End If
End Sub
Private Sub Label8deux_Click()
End Sub
Private Sub Frame1trois_Click()
End Sub
Private Sub Frame2_Click()
End Sub
Private Sub OptionButton1_Click()
End Sub
Private Sub OptionButton2_Click()
End Sub
Private Sub TextBox1trois_Change()
End Sub
Private Sub TextBox2trois_Change()
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
End Sub
'..........................................................................................................FIN DE CODE...............................................................................
ET voici mon code de mon UserForm10
Private Sub ComboBox1n_Change()
ComboBox1n = Range("P1").Select
End Sub
Private Sub ComboBox4n_Change()
End Sub
Private Sub CommandButton1n_Click()
ActiveCell.Offset(0, 38).Value = ""
ActiveCell.Offset(0, 39).Value = ""
'**********************************************************************
'PROCEDURE PERMETTANT DE FAIRE LA REDIRECTION VERS LA PAGE PRECEDENTE
'**********************************************************************
UserForm10.Hide 'fermeture le l'interface UserForm10
UserForm9.Show 'Redirection l'UserForm9
End Sub
Private Sub CommandButton2n_Click()
'Dim a As String
'Dim b As String
'Dim c As String
'Dim d As String
'Dim z As String
'a = "1 - Sonatel/Orange"
'b = "13 - Kirene"
'c = "14 - Tigo"
'd = "15 - Expresso"
'Fram operateur principal
'If OptionButton1n.Value = True Then
'z = a
'ElseIf OptionButton4n.Value = True Then
'z = b
'ElseIf OptionButton5n.Value = True Then
'z = c
'ElseIf OptionButton6n.Value = True Then
'z = d
'End If
If ComboBox4n = "" Then
Beep
MsgBox "Veuillez remplir tous les champs svp!!!"
'ElseIf OptionButton1n = False And OptionButton4n = False And OptionButton5n = False And OptionButton6n = False Then 'Il faut cocher au moins un
'Beep
'MsgBox "Veuillez remplir tous les champs svp!!!"
ElseIf ComboBox4n = "Non" Then
Beep
MsgBox "STOP INTER" 'afficher ce message STOP INTER
Else
'****************************************************
'PROCEDURE PERMETTANT DE REMPLIR LA FEUILLLE OBS3
'****************************************************
'Sheets("OBS8").Activate 'Fais les instructions ci-dessous
'Range("A1").Select
'Selection.End(xlDown).Select
'Selection.Offset(1, 0).Select
ActiveCell.Offset(0, 40).Value = ComboBox4n
ActiveCell.Offset(0, 41).Value = ComboBox1n
UserForm10.Hide 'fermeture UserForm10
UserForm11.Show 'Afficher UserForm11
End If
End Sub
Private Sub CommandButton2deux_Click()
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
ComboBox1n.List = UserForm3.ComboBox1trois.List
End Sub
'..........................................................................................................FIN DE CODE...............................................................................
Je veux remplir automatiquement mon comboBox1n via mon ComboBox1trois du UserForm3
Merci de me venir en aide
Bien cordialement
Re
Je n'ai pas lu ton code indigeste, car non indenté et très long
Mais
Private Sub UserForm_Initialize()
ComboBox1n.List = UserForm3.ComboBox1trois.List
End SubJe veux remplir automatiquement mon comboBox1n via mon ComboBox1trois du UserForm3
ton code ci-dessus cité semble bien faire ce que tu veux, à une condition que ton évènement UserForm_Initialize soit bien celui de l'userform qui contient ComboBox1n
Sinon, un petit fichier et pour indenter ton code : balise </>
A+