aurelio.ewane
XLDnaute Occasionnel
Bonjour Chers Excellsiste,
je possède une listbox avec un grand nombre de données
et je voudrais a partir d'un textbox lorsque je saisie une valeur que mon liste se filtre
c'est à dire une sorte de saisie intuitive pour pouvoir faire des recherches
pour mieux faire la recherche
je peut rechercher en saisissant
son matricule
Son nom
Son prenom
Sa date de naissance
Son Lieu de Naissance
le nom d'un parent
voila les champs ou je voudrais que ma recherche s'effectue
je joins un fichier avec ce que jai fais que je trouve très lent
Sil vous plait pouvez vous me rendre cela plus rapide et plus digeste
et aussi ma plage peut être variable
bien vouloir tenir compte de cela
voici mon code qui ne fonctionne pas
Option Base 1
Private Sub TextBox1_Change()
Call RechercheItems(2, 110, 1)
End Sub
Private Sub UserForm_Initialize()
Dim Sh As Worksheet
Set Sh = ThisWorkbook.Sheets("Base")
'Derniere ligne vide
Let LigneFin = Sh.Cells(Sh.Rows.Count, 2).End(xlUp).Row
Table = Sh.Range("B6😀F" & LigneFin)
Me.ListBox1.List() = Table
Me.ListBox1.ColumnCount = 109
'Me.ListBox1.ColumnWidths = "100;100"
Set Sh = Nothing
End Sub
Sub RechercheItems(ByVal CD As Long, ByVal CF As Long, ByVal Item As Long)
Dim Sh As Worksheet
Dim Plage, EeACellule As Range
Dim EeACounter As Long, EeAFirstAddress As Long, EeALigneFin As Long, EeANbcol As Long, EeAIndex As Long, EeAColonne As Long
Dim EeATable()
Set Sh = ThisWorkbook.Worksheets("Base")
Let EeALigneFin = Sh.Cells(Sh.Rows.Count, CD + 1).End(xlUp).Row
Let EeANbcol = CF - CD + 1
Me.FrameListBox1.ScrollTop = 0
'Call DisableAll
If Me.Controls("Textbox" & Item).Text = "" Then 'Or Me.Controls("ComboBox" & N2).Text = "Clicquer pour effectuer une recherche" Then
If EeALigneFin = 50 Then
Me.ListBox1.Enabled = False
Else
Me.ListBox1.Enabled = True
'temp = Sh.Range(Sh.Cells(51, CD), Sh.Cells(LF, CF)).Value
Me.ListBox1.List() = Sh.Range(Sh.Cells(51, CD), Sh.Cells(EeALigneFin, CF)).Value
Me.FrameListBox1.ScrollTop = 0
Me.FrameListBox1.ScrollHeight = 15 * Me.ListBox1.ListCount
'Me.Info1.Caption = "" 'Me.ListBox1.ListCount & " occurence(s) trouvée(s)"
End If
Else
If Len(Me.Controls("Textbox" & Item).Text) >= 3 Then
Me.ListBox1.Clear
Me.ListBox1.RowSource = ""
EeACounter = 0
If EeALigneFin = 50 Then
Else
With Sh.Range(Sh.Cells(51, CD), Sh.Cells(EeALigneFin, CD + 1))
Set EeACellule = .Find(Me.Controls("Textbox" & Item).Text, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not EeACellule Is Nothing Then
EeAFirstAddress = EeACellule.Row
Do
EeACounter = EeACounter + 1
ReDim Preserve EeATable(EeANbcol, EeACounter)
EeAIndex = 1
For EeAColonne = CD To CF
EeATable(EeAIndex, EeACounter) = Sh.Cells(EeACellule.Row, EeAColonne).Value
EeAIndex = EeAIndex + 1
Next EeAColonne
Set EeACellule = .FindNext(EeACellule)
Loop While Not EeACellule Is Nothing And EeACellule.Row <> EeAFirstAddress 'C.Address <> FirstAddress
If EeACounter <> 0 Then
Me.ListBox1.Column() = EeATable
Me.FrameListBox1.ScrollTop = 0
Me.FrameListBox1.ScrollHeight = 15 * Me.ListBox1.ListCount
End If
End If
'Me.Info1.Caption = Me.ListBox1.ListCount & " occurence(s) trouvée(s)"
'Me.Info1.Caption = Me.ListBox1.ListCount & " occurence(s) trouvée(s)"
End With
End If
End If
End If
'Call EnableAll
Set Sh = Nothing
Set Plage = Nothing
End Sub
je possède une listbox avec un grand nombre de données
et je voudrais a partir d'un textbox lorsque je saisie une valeur que mon liste se filtre
c'est à dire une sorte de saisie intuitive pour pouvoir faire des recherches
pour mieux faire la recherche
je peut rechercher en saisissant
son matricule
Son nom
Son prenom
Sa date de naissance
Son Lieu de Naissance
le nom d'un parent
voila les champs ou je voudrais que ma recherche s'effectue
je joins un fichier avec ce que jai fais que je trouve très lent
Sil vous plait pouvez vous me rendre cela plus rapide et plus digeste
et aussi ma plage peut être variable
bien vouloir tenir compte de cela
voici mon code qui ne fonctionne pas
Option Base 1
Private Sub TextBox1_Change()
Call RechercheItems(2, 110, 1)
End Sub
Private Sub UserForm_Initialize()
Dim Sh As Worksheet
Set Sh = ThisWorkbook.Sheets("Base")
'Derniere ligne vide
Let LigneFin = Sh.Cells(Sh.Rows.Count, 2).End(xlUp).Row
Table = Sh.Range("B6😀F" & LigneFin)
Me.ListBox1.List() = Table
Me.ListBox1.ColumnCount = 109
'Me.ListBox1.ColumnWidths = "100;100"
Set Sh = Nothing
End Sub
Sub RechercheItems(ByVal CD As Long, ByVal CF As Long, ByVal Item As Long)
Dim Sh As Worksheet
Dim Plage, EeACellule As Range
Dim EeACounter As Long, EeAFirstAddress As Long, EeALigneFin As Long, EeANbcol As Long, EeAIndex As Long, EeAColonne As Long
Dim EeATable()
Set Sh = ThisWorkbook.Worksheets("Base")
Let EeALigneFin = Sh.Cells(Sh.Rows.Count, CD + 1).End(xlUp).Row
Let EeANbcol = CF - CD + 1
Me.FrameListBox1.ScrollTop = 0
'Call DisableAll
If Me.Controls("Textbox" & Item).Text = "" Then 'Or Me.Controls("ComboBox" & N2).Text = "Clicquer pour effectuer une recherche" Then
If EeALigneFin = 50 Then
Me.ListBox1.Enabled = False
Else
Me.ListBox1.Enabled = True
'temp = Sh.Range(Sh.Cells(51, CD), Sh.Cells(LF, CF)).Value
Me.ListBox1.List() = Sh.Range(Sh.Cells(51, CD), Sh.Cells(EeALigneFin, CF)).Value
Me.FrameListBox1.ScrollTop = 0
Me.FrameListBox1.ScrollHeight = 15 * Me.ListBox1.ListCount
'Me.Info1.Caption = "" 'Me.ListBox1.ListCount & " occurence(s) trouvée(s)"
End If
Else
If Len(Me.Controls("Textbox" & Item).Text) >= 3 Then
Me.ListBox1.Clear
Me.ListBox1.RowSource = ""
EeACounter = 0
If EeALigneFin = 50 Then
Else
With Sh.Range(Sh.Cells(51, CD), Sh.Cells(EeALigneFin, CD + 1))
Set EeACellule = .Find(Me.Controls("Textbox" & Item).Text, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not EeACellule Is Nothing Then
EeAFirstAddress = EeACellule.Row
Do
EeACounter = EeACounter + 1
ReDim Preserve EeATable(EeANbcol, EeACounter)
EeAIndex = 1
For EeAColonne = CD To CF
EeATable(EeAIndex, EeACounter) = Sh.Cells(EeACellule.Row, EeAColonne).Value
EeAIndex = EeAIndex + 1
Next EeAColonne
Set EeACellule = .FindNext(EeACellule)
Loop While Not EeACellule Is Nothing And EeACellule.Row <> EeAFirstAddress 'C.Address <> FirstAddress
If EeACounter <> 0 Then
Me.ListBox1.Column() = EeATable
Me.FrameListBox1.ScrollTop = 0
Me.FrameListBox1.ScrollHeight = 15 * Me.ListBox1.ListCount
End If
End If
'Me.Info1.Caption = Me.ListBox1.ListCount & " occurence(s) trouvée(s)"
'Me.Info1.Caption = Me.ListBox1.ListCount & " occurence(s) trouvée(s)"
End With
End If
End If
End If
'Call EnableAll
Set Sh = Nothing
Set Plage = Nothing
End Sub