FullMetalKnet
XLDnaute Nouveau
Bonjour,
Je souhaiterais pouvoir remplir mes cellules via une listbox d'une userform.
voici mon projet:
sur une feuille "Sites" j'ai tous mes villes dans la colonne A dans le colonne B, C D , etc j'ai mes clients
par exemple:
A2 paris , B2 client 1 , C2 client 2 , etc
A3 Bordeaux , B3 Client 4 , etc ,
A4 Lyon , B4 Client 5 , C4 Client 6 , D4 Client 7 ,
ma macro consiste a rajouter mes clients
a partir d'une combobox je recupere ma ville et dans ma listbox mes clients de cette meme ville
j'ai rajouté un textbox pour rajouté un client dans la listbox
mon soucis est de remettre mes clients de ma listbox dans la ligne de la ville selectionné dans la combobox
voici mes codes actuelles:
Private Sub UserForm_Initialize()
Dim lig As Integer
lig = 1
With Sheets("Sites")
While .Cells(lig, 1) <> ""
ComboBox1.AddItem .Cells(lig, 1)
lig = lig + 1
Wend
End With
ComboBox1.ListIndex = 0
End Sub
Private Sub ComboBox1_Click()
'combobox ville
Dim lig As Integer
Dim Col As Integer
Col = 2
lig = ComboBox1.ListIndex + 1
ListBox1.Clear
With Sheets("Sites")
While .Cells(lig, Col) <> ""
ListBox1.AddItem .Cells(lig, Col)
Col = Col + 1
Wend
End With
ListBox1.ListIndex = -1
End Sub
Private Sub CommandButton1_Click()
'bouton rajout client dans listbox
Dim i As Integer
With Me.ListBox1
.ColumnCount = 1
.AddItem
i = .ListCount - 1
.List(i, 0) = Me.TextBox1
End With
End Sub
j'espère être assez explicite
merci d'avance
Je souhaiterais pouvoir remplir mes cellules via une listbox d'une userform.
voici mon projet:
sur une feuille "Sites" j'ai tous mes villes dans la colonne A dans le colonne B, C D , etc j'ai mes clients
par exemple:
A2 paris , B2 client 1 , C2 client 2 , etc
A3 Bordeaux , B3 Client 4 , etc ,
A4 Lyon , B4 Client 5 , C4 Client 6 , D4 Client 7 ,
ma macro consiste a rajouter mes clients
a partir d'une combobox je recupere ma ville et dans ma listbox mes clients de cette meme ville
j'ai rajouté un textbox pour rajouté un client dans la listbox
mon soucis est de remettre mes clients de ma listbox dans la ligne de la ville selectionné dans la combobox
voici mes codes actuelles:
Private Sub UserForm_Initialize()
Dim lig As Integer
lig = 1
With Sheets("Sites")
While .Cells(lig, 1) <> ""
ComboBox1.AddItem .Cells(lig, 1)
lig = lig + 1
Wend
End With
ComboBox1.ListIndex = 0
End Sub
Private Sub ComboBox1_Click()
'combobox ville
Dim lig As Integer
Dim Col As Integer
Col = 2
lig = ComboBox1.ListIndex + 1
ListBox1.Clear
With Sheets("Sites")
While .Cells(lig, Col) <> ""
ListBox1.AddItem .Cells(lig, Col)
Col = Col + 1
Wend
End With
ListBox1.ListIndex = -1
End Sub
Private Sub CommandButton1_Click()
'bouton rajout client dans listbox
Dim i As Integer
With Me.ListBox1
.ColumnCount = 1
.AddItem
i = .ListCount - 1
.List(i, 0) = Me.TextBox1
End With
End Sub
j'espère être assez explicite
merci d'avance