Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Tom LeBold
 
Posts: n/a
Default 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   Report Post  
Chip Pearson
 
Posts: n/a
Default

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" wrote in
message
...
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   Report Post  
Dave Peterson
 
Posts: n/a
Default

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
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
date in cell comment Jack Sons Excel Discussion (Misc queries) 2 July 24th 05 09:55 AM
Cell color based upon cell value My View Excel Discussion (Misc queries) 11 July 6th 05 03:59 AM
cell color index comparison MINAL ZUNKE New Users to Excel 1 June 30th 05 07:11 AM
How do you keep a comment close to the cell it relates to in Exce. EHN Excel Discussion (Misc queries) 1 April 18th 05 07:47 PM
Refrencing another cell in a worksheet that "could" exist KimberlyC Excel Worksheet Functions 1 February 7th 05 07:09 PM


All times are GMT +1. The time now is 08:35 AM.

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"