ich möchte das VBA das Excel Sheet durchsucht nach "PS:"
das sind in jedem fall die ersten 3 Zeichen der Zelle und immer in Spalte A,
danach soll mir VBA die Position der ZELLE ausgeben. Z.B. "Wort in Zeile 3 Gefunden."
Private Sub CommandButton1_Click()
Dim raFund As Range
With Worksheets("Tabelle1")
Set raFund = .Columns(1).Find(what:="PS:", LookIn:=xlValues, lookat:=xlPart)
If Not raFund Is Nothing Then
MsgBox "Wort in Zeile " & raFund.Row & " gefunden."
Else
MsgBox "Suchbegriff nicht vorhanden."
End If
End With
Private Sub CommandButton1_Click()
Dim raFund As Range
With Worksheets("Tabelle1")
Set raFund = .Columns(1).Find(what:="PS:", LookIn:=xlValues, lookat:=xlPart)
If Not raFund Is Nothing Then
Application.Goto raFund, True
'MsgBox "Wort in Zeile " & raFund.Row & " gefunden."
Else
MsgBox "Suchbegriff nicht vorhanden."
End If
End With
Set raFund = Nothing
End Sub
Ohne Meldungsausgabe, die Fundzelle wird als erste Zelle oben links angezeigt.
Option Explicit
Private Sub CommandButton1_Click()
On Error Resume Next
MsgBox "Wort in Zeile " & Evaluate("=MATCH(""PS:*"",A:A,0)") & " gefunden!"
'Oder
'Application.Goto Cells(Evaluate("=MATCH(""PS:*"",A:A,0)"), 1), True
End Sub