Wie gehts es weiter...?
26.08.2010 12:12:23
abu
Hallo Zusammen,
habe nun meine Suchfunktion soweit das sie alles macht was ich moechte:
1. Suchen nach dem Wert der in TB16 ist
2. Suchen nach dem Wert der in TB16 steht aber nur in den Zeilen die vorher durch CB1 sleektiert wurden
3. Zeigt alle an die durch CB1 vorher bestimmt wurden.
Nun moechte ich gerne das ganze um die naechste ComboBox erweitern aber mir ist nicht ganz klar ob ich das alles mit If-Bedingungen machen muss oder ob das auch irgendwie anders geht. Ich habe insgesamt 4 ComboBoxen.
Hier ist der Code der soweit funktioniert:
Private Sub ComboBox1_Change()
Dim iZeile As Integer
Sheets("Tabelle1").Range("A2:A" & Sheets("Tabelle1").Range("A65536").End(xlUp).Row).Value = _
False
With Sheets("Tabelle1")
If ComboBox1.Value = "COM" Then
ListBox1.Clear 'listbox leeren
For iZeile = ActiveSheet.CheckBoxes.Count To 2 Step -1
If Sheets("Tabelle1").Cells(iZeile, 3) = "COM" Then
Sheets("Tabelle1").Cells(iZeile, 1) = True
ListBox1.AddItem .Cells(iZeile, 2)
ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(iZeile, 3)
ListBox1.List(ListBox1.ListCount - 1, 2) = .Cells(iZeile, 4)
ListBox1.List(ListBox1.ListCount - 1, 3) = .Cells(iZeile, 5)
ListBox1.List(ListBox1.ListCount - 1, 4) = .Cells(iZeile, 6)
ListBox1.List(ListBox1.ListCount - 1, 5) = .Cells(iZeile, 7)
ListBox1.List(ListBox1.ListCount - 1, 6) = iZeile
Else
Sheets("Tabelle1").Cells(iZeile, 1) = False
End If
Next iZeile
End If
.... Hier kommt noch der selbe Code fuer alle anderen Werte die CB1 hat.
Hier der Code fuer die Suchfunktion
Private Sub CommandButton1_Click()
Dim rng As Range
Dim strFirst As String
ListBox1.Clear
With Sheets("Tabelle1")
If ComboBox1.Value = "" Then
.Range("A2:A" & Sheets("Tabelle1").Range("A65536").End(xlUp).Row).Value = False
End If
Set rng = .Range("B:G").Find(What:=TextBox16, LookAt:=xlPart)
strFirst = rng.Address
If Len(Trim(TextBox16)) = 0 And ComboBox1.Value = "" And ComboBox2.Value = "" And _
ComboBox3.Value = "" And ComboBox4.Value = "" Then Exit Sub
Do
If Not ComboBox1.Value = "" Then
If Cells(rng.Row, 1) = True Then
ListBox1.AddItem .Cells(rng.Row, 2)
ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(rng.Row, 3)
ListBox1.List(ListBox1.ListCount - 1, 2) = .Cells(rng.Row, 4)
ListBox1.List(ListBox1.ListCount - 1, 3) = .Cells(rng.Row, 5)
ListBox1.List(ListBox1.ListCount - 1, 4) = .Cells(rng.Row, 6)
ListBox1.List(ListBox1.ListCount - 1, 5) = .Cells(rng.Row, 7)
ListBox1.List(ListBox1.ListCount - 1, 6) = rng.Row
Cells(rng.Row, 1) = True
End If
Else
ListBox1.AddItem .Cells(rng.Row, 2)
ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(rng.Row, 3)
ListBox1.List(ListBox1.ListCount - 1, 2) = .Cells(rng.Row, 4)
ListBox1.List(ListBox1.ListCount - 1, 3) = .Cells(rng.Row, 5)
ListBox1.List(ListBox1.ListCount - 1, 4) = .Cells(rng.Row, 6)
ListBox1.List(ListBox1.ListCount - 1, 5) = .Cells(rng.Row, 7)
ListBox1.List(ListBox1.ListCount - 1, 6) = rng.Row
Cells(rng.Row, 1) = True
End If
Set rng = .Range("B:G").FindNext(rng)
Loop While Not rng Is Nothing And rng.Address strFirst
End With
End Sub
Ich wuerde mich freuen wenn mir jemand sagen koennte wie ich denn nun am besten weiter machen soll.
Beste Gruesse
Abu