Liste à choix multiple
Résolu
juer31
Messages postés
114
Date d'inscription
Statut
Membre
Dernière intervention
-
juer31 Messages postés 114 Date d'inscription Statut Membre Dernière intervention -
juer31 Messages postés 114 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
J'ai une liste a choix multiple (fait avec un userform) avec une liste de nom.
Lorsque j'ai fais mon choix, j'aimerais que pour chaque nom choisi, ceux-ci soit exporter sur des ligne séparer et nom une liste de nom dans une même cellule.
Est-ce possible?
Merci
Private Sub CommandButton1_Click()
'bouton valider
ActiveCell.Select
For k = 1 To ListBox1.ListCount - 1
If ListBox1.Selected(k) = True Then
tx = IIf(tx = "", ListBox1.List(k), tx & Chr(10) & ListBox1.List(k))
End If
Next
Application.EnableEvents = False
If xx <> "" And tx = "" Then ActiveCell.Value = xx
If xx = "" And tx <> "" Then ActiveCell.Value = tx
If xx <> "" And tx <> "" Then ActiveCell.Value = xx & Chr(10) & tx
If xx = "" And tx = "" Then ActiveCell.Value = ""
fin:
Application.EnableEvents = True
Unload UserForm2 'on ferme le formulaire
End Sub
Private Sub CommandButton2_Click()
Unload UserForm2 'on ferme le formulaire
End Sub
Private Sub ListBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 27 Then Unload UserForm2
End Sub
Private Sub UserForm_Activate()
Me.ListBox1.List = Feuil3.[D72:D188].Value
PauseTime = 1 ' Définit la durée.
Start = Timer ' Définit l'heure de début.
Do While Timer < Start + PauseTime
DoEvents ' Donne le contrôle à d'autres processus.
Loop
UserForm2.ListBox1.Enabled = True
ListBox1.SetFocus
End Sub
J'ai une liste a choix multiple (fait avec un userform) avec une liste de nom.
Lorsque j'ai fais mon choix, j'aimerais que pour chaque nom choisi, ceux-ci soit exporter sur des ligne séparer et nom une liste de nom dans une même cellule.
Est-ce possible?
Merci
Private Sub CommandButton1_Click()
'bouton valider
ActiveCell.Select
For k = 1 To ListBox1.ListCount - 1
If ListBox1.Selected(k) = True Then
tx = IIf(tx = "", ListBox1.List(k), tx & Chr(10) & ListBox1.List(k))
End If
Next
Application.EnableEvents = False
If xx <> "" And tx = "" Then ActiveCell.Value = xx
If xx = "" And tx <> "" Then ActiveCell.Value = tx
If xx <> "" And tx <> "" Then ActiveCell.Value = xx & Chr(10) & tx
If xx = "" And tx = "" Then ActiveCell.Value = ""
fin:
Application.EnableEvents = True
Unload UserForm2 'on ferme le formulaire
End Sub
Private Sub CommandButton2_Click()
Unload UserForm2 'on ferme le formulaire
End Sub
Private Sub ListBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 27 Then Unload UserForm2
End Sub
Private Sub UserForm_Activate()
Me.ListBox1.List = Feuil3.[D72:D188].Value
PauseTime = 1 ' Définit la durée.
Start = Timer ' Définit l'heure de début.
Do While Timer < Start + PauseTime
DoEvents ' Donne le contrôle à d'autres processus.
Loop
UserForm2.ListBox1.Enabled = True
ListBox1.SetFocus
End Sub
A voir également:
- Liste à choix multiple
- Liste déroulante excel - Guide
- Liste déroulante en cascade - Guide
- Liste code ascii - Guide
- Ecran multiple pc - Guide
- Site dangereux liste - Guide
1 réponse
Bonjour,
Ta validation modifiée selon ton souhait
Ta validation modifiée selon ton souhait
Private Sub CommandButton1_Click() 'bouton valider 'ActiveCell.Select ' inutile si activée elle est sélectionnée ReDim tx(1 To 1) For k = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(k) = True Then tx(UBound(tx)) = ListBox1.List(k) ReDim Preserve tx(1 To UBound(tx) + 1) End If Next Application.EnableEvents = False If xx <> "" And UBound(tx) = 1 Then ActiveCell.Value = xx If xx = "" And UBound(tx) > 1 Then ActiveCell.Resize(UBound(tx), 1).Value = Application.Transpose(tx) If xx <> "" And UBound(tx) > 1 Then ActiveCell.Value = xx: ActiveCell.Offset(1, 0).Resize(UBound(tx), 1).Value = Application.Transpose(tx) If xx = "" And UBound(tx) = 1 Then ActiveCell.Value = "" fin: Application.EnableEvents = True Unload UserForm2 'on ferme le formulaire End Sub
Tout est #1
Il te suffit de remplacer 'ActiveCell' par '[A6]'