Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Help with syntax on IF-Then for CellComment

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default 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" wrote in message
...
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!!





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Syntax Steve Excel Discussion (Misc queries) 2 June 21st 07 06:52 PM
look up syntax Pierre[_16_] Excel Programming 2 July 11th 05 09:01 PM
Need help with Syntax Marty Excel Programming 6 June 22nd 04 02:38 AM
Help with VBA syntax jacqui[_2_] Excel Programming 3 January 13th 04 02:29 PM
syntax Don[_13_] Excel Programming 2 November 16th 03 03:30 AM


All times are GMT +1. The time now is 05:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"