Gruppe
Allgemein
Problem
Wie erreiche ich, dass ein Suchbegriff im aktiven Blatt gesucht und jede Fundstelle über MsgBox gemeldet wird?
StandardModule: basMain
Sub Auswahl()
Dim rng As Range
Dim sBegriff As String, sAddress As String
sBegriff = InputBox( _
prompt:="Bitte Suchbegriff eingeben:", _
Default:="Hallo")
If sBegriff = "" Then Exit Sub
Set rng = Cells.Find( _
what:=sBegriff, _
lookat:=xlWhole, _
LookIn:=xlValues, _
MatchCase:=False, _
after:=ActiveCell)
If rng Is Nothing Then
Beep
MsgBox "Suchbegriff nicht gefunden!", , _
Application.UserName
Exit Sub
End If
sAddress = rng.Address
rng.Select
MsgBox rng.Address(False, False)
rng.Offset(1).Select
Do
Cells.FindNext(after:=ActiveCell).Activate
If ActiveCell.Address = sAddress Then Exit Sub
MsgBox ActiveCell.Address(False, False)
Loop
End Sub