Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I never would have stumbled on this. Thanks big time, Toppers.
I appreciate your help!! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help with Syntax | Excel Discussion (Misc queries) | |||
look up syntax | Excel Programming | |||
Need help with Syntax | Excel Programming | |||
Help with VBA syntax | Excel Programming | |||
syntax | Excel Programming |