HERBERS Excel-Forum - das Archiv
Kommentarinhalt abfragen
SteffenS

Hallo Zusammen,
wie kann ich abfragen ob ein bestimmter Text in einem Kommentar steht.
ZUm Beispiel will ich wissen ob drin steht: blaue farbe
Wie kann ich dies errreichen.
Danke im Voraus.
Steffen

AW: Kommentarinhalt abfragen
F1

Ohne Fehlerbehandlung:
Sub ordination()
If InStr([a1].Comment.Text, "blaue farbe") > 0 Then
MsgBox "Treffer!"
Else
MsgBox "Nix"
End If
End Sub

AW: Kommentarinhalt abfragen
Josef

Hallo Steffen,
das geht zB. so.
Sub findTextInComment()
  Dim objCmt As Comment
  Dim strFind As String, strTmp As String
  
  strFind = "blaue Farbe"
  
  For Each objCmt In ActiveSheet.Comments
    strTmp = objCmt.Text
    If strTmp Like "*" & strFind & "*" Then
      MsgBox "Der Suchtext '" & strFind & "' wurde" & vbLf & "Zelle " & objCmt.Parent.Address(0, 0) & " gefunden!", vbInformation, "Suche"
      Application.Goto objCmt.Parent, True
      Exit For
    End If
  Next
  
End Sub


Gruß Sepp

Wenn du das lieber im Arbeitsblatt mit...
Luc:-?

...einer Formel tun willst, Steffen,
wäre sicher diese udFkt eher was für dich... Klick! Klick!
Liest übrigens auch Text aus Textfeldern aus... ;-)
Gruß Luc :-?