AW: Habe noch vergessen
22.07.2012 16:14:01
Hajo_Zi
Hallo Kurt,
Du möchtest Deine Datei also nicht erklären. Ich bin dann raus.
Private Sub CommandButton1_Click()
Dim WkSh As Worksheet
Dim rZelle As Range
Dim sFundst As String
Dim sSuchbegriff As String
Dim iSpalte As Integer
Dim iLiBo As Integer
ListBox1.Clear
TextBox1.Value = Trim$(TextBox1.Value)
TextBox2.Value = Trim$(TextBox2.Value)
TextBox3.Value = Trim$(TextBox3.Value)
If TextBox1.Value = "" And _
TextBox2.Value = "" And _
TextBox3.Value = "" Then
MsgBox "Ohne Suchbegiff wird die Suche schwierig werden!" & Chr(10) & _
"Bitte geben Sie wenigstens einen Suchbegriff ein - danke.", _
48, " Hinweis für " & Application.UserName
TextBox1.SetFocus
Exit Sub
ElseIf TextBox1.Value "" Then
sSuchbegriff = TextBox1.Value
iSpalte = 2
ElseIf TextBox2.Value "" Then
sSuchbegriff = TextBox2.Value
iSpalte = 3
ElseIf TextBox3.Value "" Then
sSuchbegriff = TextBox3.Value
iSpalte = 4
End If
Set WkSh = ThisWorkbook.Worksheets("Aufwand")
With WkSh.Columns(iSpalte)
Set rZelle = .Find(What:=sSuchbegriff, LookAt:=xlWhole, LookIn:=xlValues, _
After:=.Cells(.Cells.Count))
'--- hiermit wird nur nach dem 1. Buchstaben gesucht ---
'Set rZelle = .Find(What:=sSuchbegriff, LookAt:=xlWhole, LookIn:=xlValues, _
After:=.Cells(.Cells.Count))
If Not rZelle Is Nothing Then
sFundst = rZelle.Address
Do
' Vergleich ob in gefunden Zeile TextBox2 in Spalte C
If TextBox2 "" Then
If Cells(rZelle.Row, 3) = TextBox2 Then
If TextBox3 "" Then
If Cells(rZelle.Row, 3) = TextBox2 Then
' Spalte A - C in Listbox
End If
Else
' Spalte A - C in Listbox
End If
' Vergleich ob in gefunden Zeile TextBox3 in Spalte D
End If
Else
If TextBox3 "" Then
If Cells(rZelle.Row, 4) = TextBox3 Then
' Spalte A - C in Listbox
End If
Else
' Spalte A - C in Listbox
End If
End If
' nächste Suche Set rZelle = .FindNext(rZelle)
Loop While Not rZelle Is Nothing And rZelle.Address sFundst
Else
MsgBox "Zu den Begriffen """ & sSuchbegriff & " / " & TextBox1.Value & _
""" wurde nichts gefunden.", _
48, " Hinweis für " & Application.UserName
End If
End With
Set rZelle = Nothing
Gruß Hajo