Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Does the current cell have a comment? (Excel 97 SR2)

    Trying to find out if the current cell has a comment and if so, what is it.
    I am getting runtime error 91: Object variable or With block variable not set when I try to assign a string variable with the contents of the comment (either activecell.comment or activecell.comment.text)

    TIA
    Alan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Does the current cell have a comment? (Excel 97 SR2)

    You can use code like this:

    Sub CellComment(rngCell As Range)
    Dim cmt As Comment
    Set cmt = rngCell.Comment
    If cmt Is Nothing Then
    MsgBox "No comment"
    Else
    MsgBox cmt.Text
    End If
    End Sub

    Instead of displaying a MsgBox, you can assign the text to a variable, etc.

  3. #3
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Does the current cell have a comment? (Excel 97 SR2)

    Many thanks Hans.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •