Paramétrage combobox dans usefrorm

  • Initiateur de la discussion Initiateur de la discussion kinel
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

kinel

XLDnaute Occasionnel
bonjour à tous

j'ai intégré un combobox dans un useform mais je ne parviens pas, avec mes petits moyens, à le paramétrer, même après la lecture de nombreux postes sur le forum.
le but est de proposer parmis 4 choix, un texte qui va se reporter dans la même feuille que les textbox déjà présents. Les choix ne doivent pas être modifiables par l'utilisateur car je vais ensuite appliquer un filtre sur la feuille.
merci de votre aide

Kinel


voici le code actuel:

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False

Dim derligne As Integer
Sheets("Liste").Select
derligne = Sheets(6).Range("A65536").End(xlUp).Row + 1
If TextBox1.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox2.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox3.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox4.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox5.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox6.Value = "" Then
Label14.Visible = True
Exit Sub
End If
With Sheets("Liste")
.Cells(derligne, 1) = TextBox1
.Cells(derligne, 2) = TextBox2
.Cells(derligne, 3) = TextBox3
.Cells(derligne, 4) = TextBox4
.Cells(derligne, 5) = CDbl(Replace(TextBox5.Value, ".", ","))
.Cells(derligne, 7) = CDbl(Replace(TextBox6.Value, ".", ","))
.Cells(derligne, 19) = DTPicker1
.Cells(derligne, 8) = DTPicker2

End With

TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
Label14.Visible = False


Application.ScreenUpdating = True

End Sub
 
Re : Paramétrage combobox dans usefrorm

Bonjour kinel

tu parles d'un "combobox" et nul par dans ton code il n'y a de référence à cet objet... Peut être qu'un petit fichier en pièce jointe, sans données confidentielles, nous aiderait à mieux cerné ton problème... Parce que en plus si il faut tout reconstruire...

bonne journée
@+

Edition : salut Romain🙂
 
Re : Paramétrage combobox dans usefrorm

voici ma partie de fichier concernée

cliquez sur le bouton ajout
mon problème se trouve au niveau de la donnée "Classe" qui doit proposer 4 choix dont l'un doit être reporté sur la feuille liste dans la colone du même nom

merci de votre aide
Kinel
 

Pièces jointes

Re : Paramétrage combobox dans usefrorm

Re

pour alimenter une combobox, tu peux procéder ainsi :

Code:
Private Sub UserForm_Initialize()
With ComboBox1
    .List = Range("A1:A4").Value
    .MatchRequired = True
End With
End Sub

A noter que dans cet exemple, la liste de choix est alimentée par les valeurs contenues sur la feuille active dans les cellules A1 à A4...

si cela peut t'aider à avancer...

@+
 
Re : Paramétrage combobox dans usefrorm

dur dur cette fois

j'ai bien intégré

With ComboBox1
.List = Range("A1:A4").Value
.MatchRequired = True
End With


dans mon code, comme ceci :

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False

Dim derligne As Integer
Sheets("Liste").Select
derligne = Sheets(6).Range("A65536").End(xlUp).Row + 1
If TextBox1.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox2.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox3.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox4.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox5.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox6.Value = "" Then
Label14.Visible = True
Exit Sub
End If
With Sheets("Liste")
.Cells(derligne, 1) = TextBox1
.Cells(derligne, 2) = TextBox2
.Cells(derligne, 3) = TextBox3
.Cells(derligne, 4) = TextBox4
.Cells(derligne, 5) = CDbl(Replace(TextBox5.Value, ".", ","))
.Cells(derligne, 7) = CDbl(Replace(TextBox6.Value, ".", ","))
.Cells(derligne, 19) = DTPicker1
.Cells(derligne, 8) = DTPicker2

End With

TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
Label14.Visible = False

With ComboBox1
.List = Sheets(Liste).Range("X1:X4").Value
.MatchRequired = True
End With

Application.ScreenUpdating = True

End Sub

mais je n'obtiens rien
ça me semble au dessus de mes petits moyens

Help me !!
 
Re : Paramétrage combobox dans usefrorm

Re

il ne faut pas l'intégrer dans le code d'un bouton mais dans l'événement "Initialize" de l'usf :

Code:
[B][COLOR="Red"]Private Sub UserForm_Initialize[/COLOR][/B]()
With ComboBox1
    .List = Range("A1:A4").Value
    .MatchRequired = True
End With
End Sub

ensuite dans ton bouton, tu peux coder :

(colonne à adapter
Code:
.Cells(derligne, [COLOR="red"][B]xx[/B][/COLOR]) =  ComboBox1.Value

@+
 
Re : Paramétrage combobox dans usefrorm

pour les lecteurs intéressés voici les bonnes lignes :

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False

Dim derligne As Integer
Sheets("Liste").Select
derligne = Sheets(6).Range("A65536").End(xlUp).Row + 1
If TextBox1.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox2.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox3.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox4.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox5.Value = "" Then
Label14.Visible = True
Exit Sub
End If
If TextBox6.Value = "" Then
Label14.Visible = True
Exit Sub
End If
With Sheets("Liste")
.Cells(derligne, 1) = TextBox1
.Cells(derligne, 2) = TextBox2
.Cells(derligne, 3) = TextBox3
.Cells(derligne, 4) = TextBox4
.Cells(derligne, 5) = CDbl(Replace(TextBox5.Value, ".", ","))
.Cells(derligne, 7) = CDbl(Replace(TextBox6.Value, ".", ","))
.Cells(derligne, 20) = ComboBox1.Value
.Cells(derligne, 19) = DTPicker1
.Cells(derligne, 8) = DTPicker2

End With

TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
Label14.Visible = False

Application.ScreenUpdating = True

End Sub

Private Sub UserForm_Initialize()
With ComboBox1
.List = Sheets(6).Range("X1:X4").Value
.MatchRequired = True
End With
End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
4
Affichages
227
  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
1 K
Réponses
9
Affichages
383
Réponses
10
Affichages
658
Réponses
5
Affichages
901
  • Question Question
Microsoft 365 Export données
Réponses
4
Affichages
900
Retour