[VBA-E]rafraichissement d'une listbox
g crée une liste de client et lorsque je rajoute un nouveau client, il ne se met pas dans ma liste. donc pour le faire apparaitre dans la listbox, j'arrete le programme et je le relance.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
Private Sub EffacerClient_Click() ' lorsque l'on efface
Dim x1 As Byte
If NumClientSel <> 0 Then
x1 = MsgBox("etes vous sur de vouloir suppriper le client " & Sheets("clients").Cells(NumClientSel, 1) & "?", vbYesNo + vbCritical, "suppression client")
If x1 = vbYes Then
Sheets("clients").Cells(NumClientSel, 8) = "oui"
UserForm_Initialize
End If
Else
MsgBox "Sélectionner un client"
End If
End Sub
Private Sub Enregistrer_Click()
Application.SaveWorkspace
End Sub
Private Sub Label18_Click()
End Sub
Private Sub ListBox1_Click() 'lorsque l'on clic sur un client ds la liste
'ListBox1.BoundColumn = 1
clientAff (Me.ListBox1.Value)
NumClientSel = Me.ListBox1.Value
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub Règlement_Change()
End Sub
Private Sub txtAdresse_Change()
End Sub
Private Sub txtHTE_Change()
txtHTE = ActiveWorkbook.Sheets(Feuil1).cell("E1")
End Sub
Private Sub UserForm_Initialize()
Dim i, j As Long
ListBox1.Clear
ListBox1.BoundColumn = 2 ' numero de de colonne lié (pour la valeur retournée par listbox.value)
i = 2 ' compteur de ligne clients (numéro de client)
j = 0 ' compteur de ligne de listbox
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = "3 cm;1 cm" ' largeur des colones a l'affichage
Do While Sheets("clients").Cells(i, 1) <> ""
If Sheets("clients").Cells(i, 8) <> "oui" Then
ListBox1.AddItem Sheets("clients").Cells(i, 1)
ListBox1.Column(1, j) = i
j = j + 1
Else
'rien
End If
i = i + 1
Loop |