Supportnet / Forum / Tabellenkalkulation
Werte in Arbeitsmappen suchen
Frage
Hallo,
ich habe wieder ein kleines Problem.
Ich möchte einen bestimmten Wert in einer Excel Arbeitsmappe mit einigen Tabellenblättern suchen.
Kann mir noch einmal jemand helfen??
MfG
Scotty
Antwort 1 von fedjo
Hallo Scotty,
in ein Modul einfügen:
Gruß
fedjo
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
in ein Modul einfügen:
Gruß
fedjo
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
Antwort 2 von Scotty69
Hi Fedjo,
danke für deine schnelle Hilfe. Bei meinen Tabellen kommt der Wert nur einmal vor. Ich brauche also nur einmal nach diesem Wert zu suchen. Wird dieser Wert innerhalb der Arbeitsmappe gefunden muß die Zelle markiert werden. Wenn er nicht gefunden wird soll eine MsgBox ausgegeben werden.
Vielleicht kannst du mir noch einmal helfen !
MfG
Scotty
danke für deine schnelle Hilfe. Bei meinen Tabellen kommt der Wert nur einmal vor. Ich brauche also nur einmal nach diesem Wert zu suchen. Wird dieser Wert innerhalb der Arbeitsmappe gefunden muß die Zelle markiert werden. Wenn er nicht gefunden wird soll eine MsgBox ausgegeben werden.
Vielleicht kannst du mir noch einmal helfen !
MfG
Scotty
Antwort 3 von fedjo
Hallo Scotty,
Code geändert wie gewünscht.
Gruß
fedjo
Option Explicit
Global SSearch As String
Public Sub Suchen()
Dim ws As Worksheet
Dim c
Dim firstAddress As String
Dim secAddress
Dim GFound As Boolean
SSearch = InputBox("Suchen nach:", "Suchen in allen Tabellen", SSearch)
If SSearch = "" Then
End
End If
For Each ws In Worksheets
With ws.Cells
Set c = .Find(SSearch, LookIn:=xlValues, MatchCase:=False)
If Not c Is Nothing Then
GFound = True
ws.Select
c.Select
Do
GoTo ende
Loop While Not c Is Nothing And secAddress <> firstAddress And c.Address <> firstAddress
Else
End If
End With
Next ws
ende:
If GFound = False Then
MsgBox "Suchwert nicht gefunden "
End If
End Sub
Code geändert wie gewünscht.
Gruß
fedjo
Option Explicit
Global SSearch As String
Public Sub Suchen()
Dim ws As Worksheet
Dim c
Dim firstAddress As String
Dim secAddress
Dim GFound As Boolean
SSearch = InputBox("Suchen nach:", "Suchen in allen Tabellen", SSearch)
If SSearch = "" Then
End
End If
For Each ws In Worksheets
With ws.Cells
Set c = .Find(SSearch, LookIn:=xlValues, MatchCase:=False)
If Not c Is Nothing Then
GFound = True
ws.Select
c.Select
Do
GoTo ende
Loop While Not c Is Nothing And secAddress <> firstAddress And c.Address <> firstAddress
Else
End If
End With
Next ws
ende:
If GFound = False Then
MsgBox "Suchwert nicht gefunden "
End If
End Sub
Antwort 4 von Scotty69
Hallo Fedjo,
so, nun ist es perfekt.
Vielen Dank
MfG
Scotty
so, nun ist es perfekt.
Vielen Dank
MfG
Scotty

