+ Reply to Thread
Results 1 to 3 of 3

Verify if Comment exist in a cell

  1. #1
    Tom LeBold
    Guest

    Verify if Comment exist in a cell

    How do you verify if a comment exist in each cell in a worksheet using VBA
    code.
    The following VBA code works for a verifying comments in a range: >If
    Range("A:A").Comment.Visible = True <

    The following VBA code does not work for verifying if comments exist in a
    cell: >
    If ActiveSheet.Cells(RowNbr, 1).Comment.Visible = True <

    Received the following error: Object varible or With block variable not set.




  2. #2
    Chip Pearson
    Guest

    Re: Verify if Comment exist in a cell

    Tom,

    Dim C As Comment
    On Error Resume Next
    Set C = Range("A1").Comment
    If Err.Number = 0 Then
    ' cell has comment, C
    Else
    ' cell does not have comment
    End If
    On Error GoTo 0


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "Tom LeBold" <TomLeBold@discussions.microsoft.com> wrote in
    message
    news:7F14A84B-97C2-4441-A9AC-FE8D491B2C9A@microsoft.com...
    > How do you verify if a comment exist in each cell in a
    > worksheet using VBA
    > code.
    > The following VBA code works for a verifying comments in a
    > range: >If
    > Range("A:A").Comment.Visible = True <
    >
    > The following VBA code does not work for verifying if comments
    > exist in a
    > cell: >
    > If ActiveSheet.Cells(RowNbr, 1).Comment.Visible = True <
    >
    > Received the following error: Object varible or With block
    > variable not set.
    >
    >
    >




  3. #3
    Dave Peterson
    Guest

    Re: Verify if Comment exist in a cell

    Another way:

    if activesheet.cells(rownbr,1).comment is nothing then
    'no comment
    else
    'yep
    end if



    Tom LeBold wrote:
    >
    > How do you verify if a comment exist in each cell in a worksheet using VBA
    > code.
    > The following VBA code works for a verifying comments in a range: >If
    > Range("A:A").Comment.Visible = True <
    >
    > The following VBA code does not work for verifying if comments exist in a
    > cell: >
    > If ActiveSheet.Cells(RowNbr, 1).Comment.Visible = True <
    >
    > Received the following error: Object varible or With block variable not set.


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1