ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting Comments (https://www.excelbanter.com/excel-programming/350649-counting-comments.html)

Geoff

Counting Comments
 
How can I programatically detect if there are any comments on a worksheet?

Geoff

Peter T

Counting Comments
 
Sub test()
Dim nComs As Long
nComs = ActiveSheet.Comments.Count

msgbox nComs

End sub

Regards,
Peter T

How can I programatically detect if there are any comments on a worksheet?

Geoff




Gary''s Student

Counting Comments
 
Try this function:


Function ccount(r As Range) As Integer
Dim C As Comment
Dim r1 As Range
ccount = 0
For Each r1 In r
On Error Resume Next
Set C = r1.Comment
If Err.Number = 0 Then
ccount = 1 + 1
End If
On Error GoTo 0
Next
End Function

--
Gary's Student


"Geoff" wrote:

How can I programatically detect if there are any comments on a worksheet?

Geoff


Geoff

Counting Comments
 
Thanks for that.

Geoff

"Peter T" wrote:

Sub test()
Dim nComs As Long
nComs = ActiveSheet.Comments.Count

msgbox nComs

End sub

Regards,
Peter T

How can I programatically detect if there are any comments on a worksheet?

Geoff






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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com