Bonjour,
Comme ceci :
Private Sub CbAjouter_Click()
Dim Table As ListObject
Set Table = Worksheets("Parametre").ListObjects("TbIdels")
If TboNom.Value <> vbnulstring And TboPrenom.Value <> vbNullString Then
With Table
If .ListRows.Count = 0 Then
.ListRows.Add: i = 1
Else: .ListRows.Add: i = .ListRows.Count 'insérer à la dernière ligne
End If
.DataBodyRange(i, 1) = UCase(TboNom.Value)
.DataBodyRange(i, 2) = StrConv(TboPrenom.Value, vbProperCase)
End With
End If
End Sub
NB : évitez l'utilisation de Rowssource, qui provoque parfois des soucis avec VBA? Préférez plutot les méthodes list ou additem
Supprimez la propriété Rowssource attribuée à votre listbox puis collez ce code dans votre userform
Private Sub UserForm_Initialize()
Dim i As Integer
Dim Table As ListObject
Set Table = Worksheets("Parametre").ListObjects("TbIdels")
With Table
For i = 1 To .ListRows.Count
LboInfi.AddItem .DataBodyRange(i, 1).Value
LboInfi.List(LboInfi.ListCount - 1, 1) = .DataBodyRange(i, 2).Value
Next i
End With
End Sub
Si ok, lors de votre réponse pensez à
Cordialement