+ Reply to Thread
Results 1 to 7 of 7

Help with syntax on IF-Then for CellComment

  1. #1
    excelnut1954
    Guest

    Help with syntax on IF-Then for CellComment

    I have a macro that will run when the user clicks a button to Find a
    Record. He enters a PO#, and all the fields for that record will appear
    on a UserForm.
    Everything works well, except that one of the textboxes is for any cell
    comment in one of the fields.

    The UserForm will display the cell comment OK, but if there is no cell
    comment in that cell, then there is an error.

    So, I want to add a line of code that will test if there IS any cell
    comment. If there is, then it can be entered in TextBox8. There is no
    need for an Else part of the statement. Here is what I have now....

    If Comment.Text = True Then
    TextBox8.Value = ActiveCell.Comment.Text

    End If

    It worked ok until I attempted to incorporate an IF-Then statement.
    I'm sure it's the 1st line that is the problem. I'm guessing on
    the syntax. >> Comment.Text = True

    The 2nd line works ok by itself. (When there IS a cell comment
    available)

    Any suggestions?

    Thanks,
    J.O.


  2. #2
    Toppers
    Guest

    RE: Help with syntax on IF-Then for CellComment

    Try this:

    If Not ActiveCell.Comment Is Nothing Then
    TextBox8.Value = ActiveCell.Comment.Text

    "excelnut1954" wrote:

    > I have a macro that will run when the user clicks a button to Find a
    > Record. He enters a PO#, and all the fields for that record will appear
    > on a UserForm.
    > Everything works well, except that one of the textboxes is for any cell
    > comment in one of the fields.
    >
    > The UserForm will display the cell comment OK, but if there is no cell
    > comment in that cell, then there is an error.
    >
    > So, I want to add a line of code that will test if there IS any cell
    > comment. If there is, then it can be entered in TextBox8. There is no
    > need for an Else part of the statement. Here is what I have now....
    >
    > If Comment.Text = True Then
    > TextBox8.Value = ActiveCell.Comment.Text
    >
    > End If
    >
    > It worked ok until I attempted to incorporate an IF-Then statement.
    > I'm sure it's the 1st line that is the problem. I'm guessing on
    > the syntax. >> Comment.Text = True
    >
    > The 2nd line works ok by itself. (When there IS a cell comment
    > available)
    >
    > Any suggestions?
    >
    > Thanks,
    > J.O.
    >
    >


  3. #3
    excelnut1954
    Guest

    Re: Help with syntax on IF-Then for CellComment

    I never would have stumbled on this. Thanks big time, Toppers.
    I appreciate your help!!


  4. #4
    Toppers
    Guest

    Re: Help with syntax on IF-Then for CellComment

    FYI, I looked in this NG to see if a similar question had been posted. And no
    surprise really .. it had. so I learned something whilst helping you!

    So not all my own work but shows the "power" of this NG.


    "excelnut1954" wrote:

    > I never would have stumbled on this. Thanks big time, Toppers.
    > I appreciate your help!!
    >
    >


  5. #5
    Tom Ogilvy
    Guest

    Re: Help with syntax on IF-Then for CellComment

    If your still in the mood to learn:

    Easier would be
    TextBox8.Value = ActiveCell.NoteText

    works whether there is a comment or not. No IF required.

    --
    Regards,
    Tom Ogilvy



    "Toppers" <[email protected]> wrote in message
    news:[email protected]...
    > FYI, I looked in this NG to see if a similar question had been posted. And

    no
    > surprise really .. it had. so I learned something whilst helping you!
    >
    > So not all my own work but shows the "power" of this NG.
    >
    >
    > "excelnut1954" wrote:
    >
    > > I never would have stumbled on this. Thanks big time, Toppers.
    > > I appreciate your help!!
    > >
    > >




  6. #6
    Toppers
    Guest

    Re: Help with syntax on IF-Then for CellComment

    Tom,
    From the "Master" .... this apprentice is always willing to
    learn !!
    Thanks.

    "Tom Ogilvy" wrote:

    > If your still in the mood to learn:
    >
    > Easier would be
    > TextBox8.Value = ActiveCell.NoteText
    >
    > works whether there is a comment or not. No IF required.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    >
    > "Toppers" <[email protected]> wrote in message
    > news:[email protected]...
    > > FYI, I looked in this NG to see if a similar question had been posted. And

    > no
    > > surprise really .. it had. so I learned something whilst helping you!
    > >
    > > So not all my own work but shows the "power" of this NG.
    > >
    > >
    > > "excelnut1954" wrote:
    > >
    > > > I never would have stumbled on this. Thanks big time, Toppers.
    > > > I appreciate your help!!
    > > >
    > > >

    >
    >
    >


  7. #7
    excelnut1954
    Guest

    Re: Help with syntax on IF-Then for CellComment

    Thanks to both of you. I appreciate the help both of you provide.
    J.O.


+ 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