Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Listbox mit ComboBox Filtern

Forumthread: Listbox mit ComboBox Filtern

Listbox mit ComboBox Filtern
26.10.2020 13:54:26
michi
Hallo Ihr Excel Profis
Hoffe Ihr könnt mir weiter Helfen, habe eine Userform und dort holt die Listbox entsprechende Daten.
Nun möchte ich, innerhalb der Listbox Ansicht Filtern über eine ComboBox nach Aktiv oder Inaktiv.
Bei meinem Code Filtert es aber sehr ungenau und mischt immer Aktiv und Inaktiv zusammen.
Ich hoffe Ihr könnt mir weiter helfen. Danke viel mal.
Hier anbei mein Code:
Sub Filter()
Dim rngcellName As Range
Dim Name As String
Dim Suchwort As String
With Worksheets("Mitglieder").Range("AN5:AN" & Rows.Count)
UserForm2.ListBox6.Clear
Set rngcellName = Worksheets("Mitglieder").Range("AN5:AN" & Rows.Count).Find(What: _
=UserForm2.ComboBox8, _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:= _
xlNext, MatchCase:=True)
Suchwort = UserForm2.ComboBox8
If Not rngcellName Is Nothing Then
Name = rngcellName.Address
Do
With UserForm2.ListBox6
.ColumnCount = 7
.AddItem
.List(.ListCount - 1, 0) = rngcellName.Offset(-1, -39).Value  'ID
.List(.ListCount - 1, 1) = rngcellName.Offset(-1, -38).Value  'Anrede
.List(.ListCount - 1, 2) = rngcellName.Offset(-1, -37).Value  'Betreuer
.List(.ListCount - 1, 3) = rngcellName.Offset(-1, -36).Value  'Anwesend
.List(.ListCount - 1, 4) = rngcellName.Offset(-1, -35).Value  'Entschuldigt
.List(.ListCount - 1, 5) = rngcellName.Offset(-1, -34).Value  ' _
Unentschuldigt
.List(.ListCount - 1, 6) = rngcellName.Offset(-1, 0).Value    'Status
End With
Set rngcellName = .FindNext(rngcellName)
Loop While Not rngcellName Is Nothing And rngcellName.Address  Name
End If
End With
End Sub
Bedanke mir für eure hilfe.
Lg Michi
Anzeige

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Listbox mit ComboBox Filtern
26.10.2020 13:57:48
Nepumuk
Hallo Michi,
lade bitte eine Mustermappe hoch.
Gruß
Nepumuk
AW: Listbox mit ComboBox Filtern
26.10.2020 15:00:16
michi
Hallo Nebumuk
Danke für die Info.
Ich werde es probieren, aber da meine Datei sehr gross ist wird es nicht einfach sein.
AW: Listbox mit ComboBox Filtern
26.10.2020 15:02:57
Nepumuk
Hallo Michi,
schmeiß alle Tabellen außer der "Mitglieder" raus und verfremde die Daten. Mehr brauche ich nicht.
Gruß
Nepumuk
Anzeige
AW: Listbox mit ComboBox Filtern
26.10.2020 15:57:08
Nepumuk
Hallo Michi,
so besser?
Option Explicit

Private Sub ComboBox8_Change()
    Call Filter
End Sub

Sub Filter()
    
    Dim rngcellName As Range
    Dim strFirstAddress As String
    
    ListBox6.Clear
    
    With Worksheets("Mitglieder").Columns(40)
        
        Set rngcellName = .Find(What:=ComboBox8.Text, _
            LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True)
        
        If Not rngcellName Is Nothing Then
            
            strFirstAddress = rngcellName.Address
            
            Do
                
                With ListBox6
                    
                    .AddItem
                    .List(.ListCount - 1, 0) = rngcellName.Offset(0, -39).Value
                    .List(.ListCount - 1, 1) = rngcellName.Offset(0, -38).Value
                    .List(.ListCount - 1, 2) = rngcellName.Offset(0, -37).Value
                    .List(.ListCount - 1, 3) = rngcellName.Offset(0, -36).Value
                    .List(.ListCount - 1, 4) = rngcellName.Offset(0, -35).Value
                    .List(.ListCount - 1, 5) = rngcellName.Offset(0, -34).Value
                    .List(.ListCount - 1, 6) = rngcellName.Offset(0, 0).Value
                    
                End With
                
                Set rngcellName = .FindNext(rngcellName)
                
            Loop Until rngcellName.Address = strFirstAddress
        End If
    End With
End Sub

Private Sub UserForm_Initialize()
    ListBox6.ColumnCount = 7
    ComboBox8.List = Array("Aktiv", "Inaktiv")
End Sub

Gruß
Nepumuk
Anzeige
AW: Listbox mit ComboBox Filtern
26.10.2020 16:05:37
michi
Hallo Nepumuk
Und wie, das ist echt super.
Ich bedanke mich sehr für deine Hilfe.
Hast mir echt geholfen. DANKE!
Wünsche Dir noch einen schönen Abend
Lg Michi
;

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige