Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Tom is offline
external usenet poster
 
Posts: 44
Default HasComment ?!?

Hi

I'd like to check, if the cell A1 contains a comment. If yes, the comment
should be deleted. But the problem is, that the HasComment-property is not
available. How to do?

Tom


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default HasComment ?!?

Tom,

Here's a small UDF to do it

Function HasComment(rng As Range)
If rng.Count 1 Then
HasComment = CVErr(xlErrValue)
Else
HasComment = Not (rng.Comment Is Nothing)
End If
End Function

=HasComment(A1) returns TRUE or FALSE as appropriate
=HasComment(A1:A2) returns #VALUE (more than 1 cell being referenced)

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Tom" wrote in message
...
Hi

I'd like to check, if the cell A1 contains a comment. If yes, the comment
should be deleted. But the problem is, that the HasComment-property is not
available. How to do?

Tom




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default HasComment ?!?


Sub Macro1()
Dim c As Comment

For Each c In ActiveSheet.Comments
If c.Parent.Address = Range("A1").Address Then
c.Delete
End If
Next

End Sub

"Tom" wrote in message
...
Hi

I'd like to check, if the cell A1 contains a comment. If yes, the comment
should be deleted. But the problem is, that the HasComment-property is not
available. How to do?

Tom




  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Tom is offline
external usenet poster
 
Posts: 44
Default HasComment ?!?

Thanks a lot!

Tom



"John" <john.iseppi.iinet.net.au schrieb im Newsbeitrag
...

Sub Macro1()
Dim c As Comment

For Each c In ActiveSheet.Comments
If c.Parent.Address = Range("A1").Address Then
c.Delete
End If
Next

End Sub

"Tom" wrote in message
...
Hi

I'd like to check, if the cell A1 contains a comment. If yes, the

comment
should be deleted. But the problem is, that the HasComment-property is

not
available. How to do?

Tom






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default HasComment ?!?

Bob,

Posted my suggestion below.

I like your suggestion too. I forgot about "Is Nothing", - good one.

regards,

John


"Bob Phillips" wrote in message
...
Tom,

Here's a small UDF to do it

Function HasComment(rng As Range)
If rng.Count 1 Then
HasComment = CVErr(xlErrValue)
Else
HasComment = Not (rng.Comment Is Nothing)
End If
End Function

=HasComment(A1) returns TRUE or FALSE as appropriate
=HasComment(A1:A2) returns #VALUE (more than 1 cell being referenced)

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Tom" wrote in message
...
Hi

I'd like to check, if the cell A1 contains a comment. If yes, the

comment
should be deleted. But the problem is, that the HasComment-property is

not
available. How to do?

Tom








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default HasComment ?!?

For the user's stated problem, how about just

Sub RemoveA1Comment
On Error Resume Next
Range("A1").Comment.Delete
End Sub


On Fri, 22 Aug 2003 18:37:33 +1000, "John" <john.iseppi.iinet.net.au wrote:


Sub Macro1()
Dim c As Comment

For Each c In ActiveSheet.Comments
If c.Parent.Address = Range("A1").Address Then
c.Delete
End If
Next

End Sub

"Tom" wrote in message
...
Hi

I'd like to check, if the cell A1 contains a comment. If yes, the comment
should be deleted. But the problem is, that the HasComment-property is not
available. How to do?

Tom




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



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

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

About Us

"It's about Microsoft Excel"