Hallo,
ich habe einen VBA Code der in einer Tabelle suchen soll und und ein Ergebnis anzeigt. Anschließend kommt eine Abfrage, ob weitergesucht werden soll. Leider kommt bei der Auswahl "weitersuchen" eine Fehlermeldung, die auf folgende Zeile hinweißt:
Set rZelle = .FindNext(TextBox1.Value, LookAt:=xlWhole, LookIn:= _
xlValues)
Kann mir jemand helfen? Ich beginne erst mit VBA und meine Kenntnisse sind daher begrenzt. Würde mcih echt freuen.
Private Sub CommandButton1_Click()
Dim WkSh As Worksheet
Dim rZelle As Range
Dim i As Integer, Qe As Long
Set WkSh = ThisWorkbook.Worksheets("Tabelle1")
If TextBox1.Value <> "" Then
For i = 1 To 3 Step 2
With WkSh.Columns(i)
Set rZelle = .Find(TextBox1.Value, LookAt:=xlWhole, LookIn:=xlValues)
If Not rZelle Is Nothing Then
TextBox2.Value = WkSh.Cells(rZelle.Row, 1).Value
TextBox3.Value = WkSh.Cells(rZelle.Row, 2).Value
TextBox4.Value = WkSh.Cells(rZelle.Row, 3).Value
Qe = MsgBox("Möchten Sie weitersuchen ?", vbYesNo, "Suche")
If Qe = vbYes Then
Do Until Qe = vbNo
Set rZelle = .FindNext(TextBox1.Value, LookAt:=xlWhole, LookIn:= _
xlValues)
If Not rZelle Is Nothing Then
TextBox2.Value = WkSh.Cells(rZelle.Row, 1).Value
TextBox3.Value = WkSh.Cells(rZelle.Row, 2).Value
TextBox4.Value = WkSh.Cells(rZelle.Row, 3).Value
Qe = MsgBox("Möchten Sie weitersuchen ?", vbYesNo, "Suche")
End If
Loop
End If
Else
MsgBox "Der gesuchte Begriff """ & TextBox1.Value & _
""" wurde nicht gefunden.", _
48, " Hinweis für " & Application.UserName
TextBox1.SetFocus
End If
End With
Next i
Else
MsgBox "Sie müssen einen Suchbegriff eingeben - danke." & _
48, " Hinweis für " & Application.UserName
TextBox1.SetFocus
End If
End Sub
|