Bonjour,
je reviens ici car j'ai un souci de débeguage erreur d'execution 13 incompatibilité de type
je souhaite pouvoir faire des modification dans la listbox1
c'est a partir de Private Sub Modifier_Click() que les problèmes commence je joint le fichier
merci d'avance
Dim f, choix(), Rng, Ncol
Private Sub UserForm_Initialize()
Set f = Sheets("bd")
Set Rng = f.Range("a3:F" & f.[a65000].End(xlUp).Row)
TblTmp = Rng.Value
Ncol = Rng.Columns.Count
For I = LBound(TblTmp) To UBound(TblTmp)
ReDim Preserve choix(1 To I)
For k = LBound(TblTmp) To UBound(TblTmp, 2)
choix(I) = choix(I) & TblTmp(I, k) & " * "
Next k
Next I
Me.ListBox1.List = Rng.Value
End Sub
Private Sub TextBox1_Change()
If Me.TextBox1 <> "" Then
mots = Split(Trim(Me.TextBox1), " ")
Tbl = choix
For I = LBound(mots) To UBound(mots)
Tbl = Filter(Tbl, mots(I), True, vbTextCompare)
Next I
n = 0: Dim b()
For I = LBound(Tbl) To UBound(Tbl)
a = Split(Tbl(I), "*")
n = n + 1: ReDim Preserve b(1 To Ncol, 1 To n)
For k = 1 To Ncol
b(k, I + 1) = a(k - 1)
Next k
Next I
If n > 0 Then
ReDim Preserve b(1 To Ncol, 1 To n + 1)
Me.ListBox1.List = Application.Transpose(b)
Me.ListBox1.RemoveItem n
End If
Me.Label1.Caption = UBound(Tbl) + 1
Else
UserForm_Initialize
End If
End Sub
Private Sub ListBox1_Click()
For k = 0 To Ncol - 1
Me("TextBox" & k + 2) = Me.ListBox1.Column(k)
Next k
End Sub
Private Sub Modifier_Click()
Dim LI As Integer
Dim I As Byte
If Me.ListBox1.ListIndex = -1 Then
End If
For I = 1 To 6
f.Cells(ListBox1.Column(0, ListBox1.ListIndex), I).Value = Me.Controls("TextBox" & I + 2): Me.Controls("TExtBox" & I + 2).Value = ""
Next I
Me.TextBox1.Value = ""
Me.TextBox1.Value = f.Cells(LI, 1).Value
End Sub
je reviens ici car j'ai un souci de débeguage erreur d'execution 13 incompatibilité de type
je souhaite pouvoir faire des modification dans la listbox1
c'est a partir de Private Sub Modifier_Click() que les problèmes commence je joint le fichier
merci d'avance
Dim f, choix(), Rng, Ncol
Private Sub UserForm_Initialize()
Set f = Sheets("bd")
Set Rng = f.Range("a3:F" & f.[a65000].End(xlUp).Row)
TblTmp = Rng.Value
Ncol = Rng.Columns.Count
For I = LBound(TblTmp) To UBound(TblTmp)
ReDim Preserve choix(1 To I)
For k = LBound(TblTmp) To UBound(TblTmp, 2)
choix(I) = choix(I) & TblTmp(I, k) & " * "
Next k
Next I
Me.ListBox1.List = Rng.Value
End Sub
Private Sub TextBox1_Change()
If Me.TextBox1 <> "" Then
mots = Split(Trim(Me.TextBox1), " ")
Tbl = choix
For I = LBound(mots) To UBound(mots)
Tbl = Filter(Tbl, mots(I), True, vbTextCompare)
Next I
n = 0: Dim b()
For I = LBound(Tbl) To UBound(Tbl)
a = Split(Tbl(I), "*")
n = n + 1: ReDim Preserve b(1 To Ncol, 1 To n)
For k = 1 To Ncol
b(k, I + 1) = a(k - 1)
Next k
Next I
If n > 0 Then
ReDim Preserve b(1 To Ncol, 1 To n + 1)
Me.ListBox1.List = Application.Transpose(b)
Me.ListBox1.RemoveItem n
End If
Me.Label1.Caption = UBound(Tbl) + 1
Else
UserForm_Initialize
End If
End Sub
Private Sub ListBox1_Click()
For k = 0 To Ncol - 1
Me("TextBox" & k + 2) = Me.ListBox1.Column(k)
Next k
End Sub
Private Sub Modifier_Click()
Dim LI As Integer
Dim I As Byte
If Me.ListBox1.ListIndex = -1 Then
End If
For I = 1 To 6
f.Cells(ListBox1.Column(0, ListBox1.ListIndex), I).Value = Me.Controls("TextBox" & I + 2): Me.Controls("TExtBox" & I + 2).Value = ""
Next I
Me.TextBox1.Value = ""
Me.TextBox1.Value = f.Cells(LI, 1).Value
End Sub