View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
[email protected] riccifs@tin.it is offline
external usenet poster
 
Posts: 37
Default count comments funtion

On Jan 10, 5:10 pm, "Rick Rothstein \(MVP - VB\)"
wrote:
I'd like to make it automatic when I add and/or when I delete a
comment
I tried with "Application.Volatile True" but it does not work.


I don't have an answer as to how to do this (it appears that adding and deleting comments doesn't generate any events); however, unless I missed something, this function appears to do what your originally posted code does, but is a little bit shorter...

Public Function CommentCount(MyRange As Range)
Dim cell As Range
On Error Resume Next
For Each cell In MyRange
CommentCount = CommentCount - (cell.Comment.Text < "")
Next cell
End Function

Rick


Hi Rick,
many thanks the same for help!

Bye, Stefano.