Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Detect Comment + Happy Christmas

Greetings fellow VBA geeks and a happy Christmas

anybody know the syntax for detecting if a cell contains a
comment or not...??

Let's hope that Beagle 2 is just messing about and forgot
to phone home for a laugh...

Rgds

Chris
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Detect Comment + Happy Christmas

Chris,

Try something like


Dim Cmt As Comment
On Error Resume Next
Set Cmt = ActiveCell.Comment
If Cmt Is Nothing Then
MsgBox "No comment"
Else
MsgBox "Has comment: " & Cmt.Text
End If
On Error GoTo 0



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


"Chris Gorham" wrote in
message ...
Greetings fellow VBA geeks and a happy Christmas

anybody know the syntax for detecting if a cell contains a
comment or not...??

Let's hope that Beagle 2 is just messing about and forgot
to phone home for a laugh...

Rgds

Chris



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Detect Comment + Happy Christmas


Hi,

Try this,

Function DetectComment(rng As Range) As Boolean
On Error Resume Next
Dim cmtcell As Range
If rng.Count = 1 Then
If Not rng.Comment Is Nothing Then
DetectComment = True
Err.Clear
Exit Function
End If
Else
Set cmtcell = rng.SpecialCells(xlCellTypeComments)
Err.Clear
End If
If Not cmtcell Is Nothing Then
DetectComment = True
End If
End Function

Sub Test()

If DetectComment(Selection) Then
MsgBox "Comment Found"
Else
MsgBox "Comment Not Found"
End If
End Sub

Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
VB ; How do I detect a Comment in a cell rdwj Excel Discussion (Misc queries) 5 June 4th 08 09:17 PM
Please Reply to this Thanks to all - Merry Xmas!, Happy Chanukah!, Happy ID Stan Excel Discussion (Misc queries) 0 December 23rd 07 04:34 AM
What I'd like for Christmas.... Gklass Charts and Charting in Excel 3 October 9th 07 07:14 PM
MERRY CHRISTMAS Martin ©¿©¬ [email protected] Excel Discussion (Misc queries) 0 December 12th 06 01:19 PM
Merry Christmas To All Rocky McKinley Excel Programming 1 December 26th 03 01:24 AM


All times are GMT +1. The time now is 05:54 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"