afficher sous une chaine de caractère les valeurs d'une listbox

B

ben

Guest
Bonjour le forum,,

Je cherche comment faire pour ressortir sous une chaine de caractère avec un "+" entre les valeurs les valeurs d'une listbox

Merci pour votre aide
 
W

wally

Guest
Bonjour ben et le forum,

Essaye ceci (à partir d'une ligne de commande) :

Private Sub CommandButton1_Click()

Dim sTxt As String
Dim iRow As Integer

For iRow = 0 To UserForm1.ListBox1.ListCount - 1
If sTxt = "" Then
sTxt = UserForm1.ListBox1.List(iRow)
Else
sTxt = sTxt & "+" & UserForm1.ListBox1.List(iRow)
End If
Next iRow

MsgBox sTxt

End Sub


Slts

wally
 
B

ben

Guest
re wally et le forum

wally ca fonctionne bien mais j'ai un petit souci ds mon contexte :
La chaine de caractère fonctionne bien, mais au moment de ma comparaison sur une celulle celle ci peut avec la possibilité d'être dans le désordre

exemple je compare les élément de ma litbox (BA01A+BA01B) à ma celulle (BA01B+BA01A) dans mon contexte je n'aurrai mon résultat attentu car se n'est pas la meme chaine.

As tu une solution pour m'aide de gérer une chaine ds le désordre également ca m'a l'air un peu chaud !!!

Voici mon code (ta vu a part ton code j'ai réussi a faire tout seul en reprenant les code que tu m'avais fais je viens bon lol)

Private Sub CommandButton3_Click()
UserForm1.TextBox1.Value = ""
Dim orge As Range
Dim sTxt As String
Dim iRow As Integer
Dim resultat As String
Dim tot As Integer


For iRow = 0 To UserForm1.lsb_selection_item.ListCount - 1
If sTxt = "" Then
sTxt = UserForm1.lsb_selection_item.List(iRow)
Else
sTxt = sTxt & "+" & UserForm1.lsb_selection_item.List(iRow)
End If
Next iRow

resultat = sTxt


If UserForm1.lsb_selection_item.ListCount >= 2 Then
Sheets("gestion des mariages").Select
For Each orge In ActiveSheet.Range("A3:A" & ActiveSheet.Range("B65536").End(xlUp).Row)
If orge.Value = UserForm1.cbx_choix_machine.Value _
And orge.Offset(0, 1).Value = UserForm1.txt_choix_item.Value _
And orge.Offset(0, 2).Value = resultat Then
UserForm1.TextBox1.Value = orge.Offset(0, 3).Value
End If
Next orge
Else
Sheets(UserForm1.cbx_choix_machine.Value).Activate
For Each orge In ActiveSheet.Range("B2:B" & ActiveSheet.Range("B65536").End(xlUp).Row)
If orge.Value = resultat _
And orge.Offset(0, 1) = UserForm1.txt_choix_item.Value Then
UserForm1.TextBox1.Value = orge.Offset(0, 2).Value
End If
Next orge
End If

End Sub
 

Statistiques des forums

Discussions
314 093
Messages
2 105 789
Membres
109 430
dernier inscrit
dede746