Ich habe unten stehendes Script gefunden, damit kann ein Suchbegriff eingegeben und über alle Tabellen gesucht und angezeigt werden. Jedoch möchte ich nun, dass nur in der aktiven Tabelle gesucht wird.
Ich habe "Public strSuch As String" durch "Private..." ersetzt, das hat jedoch nicht funktioniert. Wie müsste das Script angepasst werden?
Option Explicit
Public strSuch As String
Private Sub CommandButton2_Click()
Dim Wks As Worksheet
Dim rng As Range
Dim strAddress As String, strFind As String
strFind = InputBox("Bitte Suchbegriff eingeben:", Application.UserName, strSuch)
If strFind = "" Then Exit Sub
For Each Wks In Worksheets
Set rng = Wks.Cells.Find(strFind, lookat:=xlPart, LookIn:=xlFormulas)
If Not rng Is Nothing Then
strAddress = rng.Address
Do
Application.GoTo rng, False
If MsgBox("Weiter", vbYesNo + vbQuestion) = vbNo Then Exit Sub
Set rng = Cells.FindNext(After:=ActiveCell)
If rng.Address = strAddress Then Exit Do
Loop
End If
Next Wks
strSuch = strFind
MsgBox "Keine weiteren Fundstellen!", False, Application.UserName
Worksheets(1).Activate
Range("A1").Select
End Sub
Vielen Dank für Eure Unterstützung.
Viele Grüsse,
Peter