Meine Suchefunktion ist buggy
29.05.2008 11:16:58
Dominik
Hier mein kompleter Code für meine Suchfuntkion ... das problem ist ... manchmal sucht er nach dem kompleten eintrag ... und manchmal nach stücken ... wie kann man das lösen das er immer nach allem sucht ?
Option Explicit
Global SSearch As String
Public Sub SearchAllTables()
Dim ws As Worksheet
Dim c
Dim firstAddress As String
Dim secAddress
Dim GFound As Boolean
Dim GWeiter As Boolean
GWeiter = False
GFound = False
anf:
SSearch = InputBox("Suchen nach:", "Search In All Tables", SSearch)
If SSearch = "" Then
End
End If
weiter:
For Each ws In Worksheets
'ws.Select
With ws.Cells
Set c = .Find(SSearch, LookIn:=xlValues, MatchCase:=False)
If Not c Is Nothing Then
GFound = True
ws.Select
c.Select
firstAddress = c.Address
If MsgBox("Weitersuchen ?", vbQuestion + vbYesNo) = vbYes Then
Do
Set c = .FindNext(c)
secAddress = c.Address
If c.Address = firstAddress Then
Exit Do
End If
c.Select
If MsgBox("Weitersuchen ?", vbQuestion + vbYesNo) = vbNo Then
GWeiter = True
GoTo ende
End If
Loop While Not c Is Nothing And secAddress firstAddress And c.Address _
firstAddress
Else
GWeiter = True
GoTo ende
End If
End If
End With
Next ws
ende:
If GFound = False Then
If MsgBox("Suchwert nicht gefunden ! Neue Suche ?", vbInformation + vbYesNo) = vbYes _
Then
GoTo anf:
End If
Else
If GWeiter = False Then
If MsgBox("Sie haben alle Tabellenblätter durchsucht ! Soll die Suche neu gestartet _
werden ?", vbInformation + vbYesNo) = vbYes Then
GoTo weiter
End If
End If
End If
End Sub