Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default count comments funtion

Hi to everyone,
does anyone to know how to build a function, not a macro, to count the
number of comments in a cells range?

searching to this news group I found this code:

Public Function CommentCount()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In Selection
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function

but it doesn't seem to work for me. Can someone help me?

I really do appreciate who will give to me an hand
Bye,Stefano.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default count comments funtion

Hi,

Sending a range to it looks simpler
call with
=CommentCount(A1:a100)
Not it must be inserted in a module

Public Function CommentCount(MyRange As Range)
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In MyRange
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function

" wrote:

Hi to everyone,
does anyone to know how to build a function, not a macro, to count the
number of comments in a cells range?

searching to this news group I found this code:

Public Function CommentCount()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In Selection
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function

but it doesn't seem to work for me. Can someone help me?

I really do appreciate who will give to me an hand
Bye,Stefano.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default count comments funtion

On Jan 10, 1:27 pm, Mike H wrote:
Hi,

Sending a range to it looks simpler
call with
=CommentCount(A1:a100)
Not it must be inserted in a module

Public Function CommentCount(MyRange As Range)
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In MyRange
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function

" wrote:
Hi to everyone,
does anyone to know how to build a function, not a macro, to count the
number of comments in a cells range?


searching to this news group I found this code:


Public Function CommentCount()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In Selection
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


but it doesn't seem to work for me. Can someone help me?


I really do appreciate who will give to me an hand
Bye,Stefano.


Hi Mike,
now it works very well!

Many many thanks for the great help you give to me,
Bye, Stefano.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default count comments funtion

On Jan 10, 1:56 pm, wrote:
On Jan 10, 1:27 pm, Mike H wrote:



Hi,


Sending a range to it looks simpler
call with
=CommentCount(A1:a100)
Not it must be inserted in a module


Public Function CommentCount(MyRange As Range)
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In MyRange
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


" wrote:
Hi to everyone,
does anyone to know how to build a function, not a macro, to count the
number of comments in a cells range?


searching to this news group I found this code:


Public Function CommentCount()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In Selection
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


but it doesn't seem to work for me. Can someone help me?


I really do appreciate who will give to me an hand
Bye,Stefano.


Hi Mike,
now it works very well!

Many many thanks for the great help you give to me,
Bye, Stefano.


Hi Mike,
let me ask to you just a last thing.

Do you know how to automatic update that formula?
I mean, without hit enter every time, on the cell where I insert the
function.

Bye, Stefano.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default count comments funtion

On Jan 10, 1:56 pm, wrote:
On Jan 10, 1:27 pm, Mike H wrote:



Hi,


Sending a range to it looks simpler
call with
=CommentCount(A1:a100)
Not it must be inserted in a module


Public Function CommentCount(MyRange As Range)
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In MyRange
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


" wrote:
Hi to everyone,
does anyone to know how to build a function, not a macro, to count the
number of comments in a cells range?


searching to this news group I found this code:


Public Function CommentCount()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In Selection
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


but it doesn't seem to work for me. Can someone help me?


I really do appreciate who will give to me an hand
Bye,Stefano.


Hi Mike,
now it works very well!

Many many thanks for the great help you give to me,
Bye, Stefano.


Hi Mike,
let me ask to you just a last thing.

Do you know how to automatic update that formula?
I mean, without hit enter every time, on the cell where I insert the
function.

Bye, Stefano.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default count comments funtion

On Jan 10, 1:56 pm, wrote:
On Jan 10, 1:27 pm, Mike H wrote:



Hi,


Sending a range to it looks simpler
call with
=CommentCount(A1:a100)
Not it must be inserted in a module


Public Function CommentCount(MyRange As Range)
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In MyRange
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


" wrote:
Hi to everyone,
does anyone to know how to build a function, not a macro, to count the
number of comments in a cells range?


searching to this news group I found this code:


Public Function CommentCount()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In Selection
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


but it doesn't seem to work for me. Can someone help me?


I really do appreciate who will give to me an hand
Bye,Stefano.


Hi Mike,
now it works very well!

Many many thanks for the great help you give to me,
Bye, Stefano.


Hi Mike,
let me ask to you just a last thing.

Do you know how to automatic update that formula?
I mean, without hit enter every time, on the cell where I insert the
function.

Bye, Stefano.
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default count comments funtion

Hi,

Tap F9

Mike

" wrote:

On Jan 10, 1:56 pm, wrote:
On Jan 10, 1:27 pm, Mike H wrote:



Hi,


Sending a range to it looks simpler
call with
=CommentCount(A1:a100)
Not it must be inserted in a module


Public Function CommentCount(MyRange As Range)
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In MyRange
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


" wrote:
Hi to everyone,
does anyone to know how to build a function, not a macro, to count the
number of comments in a cells range?


searching to this news group I found this code:


Public Function CommentCount()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In Selection
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


but it doesn't seem to work for me. Can someone help me?


I really do appreciate who will give to me an hand
Bye,Stefano.


Hi Mike,
now it works very well!

Many many thanks for the great help you give to me,
Bye, Stefano.


Hi Mike,
let me ask to you just a last thing.

Do you know how to automatic update that formula?
I mean, without hit enter every time, on the cell where I insert the
function.

Bye, Stefano.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default count comments funtion

On Jan 10, 2:46 pm, Mike H wrote:
Hi,

Tap F9

Mike

" wrote:
On Jan 10, 1:56 pm, wrote:
On Jan 10, 1:27 pm, Mike H wrote:


Hi,


Sending a range to it looks simpler
call with
=CommentCount(A1:a100)
Not it must be inserted in a module


Public Function CommentCount(MyRange As Range)
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In MyRange
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


" wrote:
Hi to everyone,
does anyone to know how to build a function, not a macro, to count the
number of comments in a cells range?


searching to this news group I found this code:


Public Function CommentCount()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In Selection
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


but it doesn't seem to work for me. Can someone help me?


I really do appreciate who will give to me an hand
Bye,Stefano.


Hi Mike,
now it works very well!


Many many thanks for the great help you give to me,
Bye, Stefano.


Hi Mike,
let me ask to you just a last thing.


Do you know how to automatic update that formula?
I mean, without hit enter every time, on the cell where I insert the
function.


Bye, Stefano.


Hi Mike,
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.

Bye, Stefano.

P.S.
sorry for the double previous post, I make I mistake.
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default count comments funtion

On Jan 10, 1:56 pm, wrote:
On Jan 10, 1:27 pm, Mike H wrote:



Hi,


Sending a range to it looks simpler
call with
=CommentCount(A1:a100)
Not it must be inserted in a module


Public Function CommentCount(MyRange As Range)
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In MyRange
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


" wrote:
Hi to everyone,
does anyone to know how to build a function, not a macro, to count the
number of comments in a cells range?


searching to this news group I found this code:


Public Function CommentCount()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In Selection
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


but it doesn't seem to work for me. Can someone help me?


I really do appreciate who will give to me an hand
Bye,Stefano.


Hi Mike,
now it works very well!

Many many thanks for the great help you give to me,
Bye, Stefano.


Hi Mike,
let me ask to you just a last thing.

Do you know how to automatic update that formula?
I mean, without hit enter every time, on the cell where I insert the
function.

Bye, Stefano.
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default count comments funtion

On Jan 10, 1:56 pm, wrote:
On Jan 10, 1:27 pm, Mike H wrote:



Hi,


Sending a range to it looks simpler
call with
=CommentCount(A1:a100)
Not it must be inserted in a module


Public Function CommentCount(MyRange As Range)
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In MyRange
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


" wrote:
Hi to everyone,
does anyone to know how to build a function, not a macro, to count the
number of comments in a cells range?


searching to this news group I found this code:


Public Function CommentCount()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In Selection
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


but it doesn't seem to work for me. Can someone help me?


I really do appreciate who will give to me an hand
Bye,Stefano.


Hi Mike,
now it works very well!

Many many thanks for the great help you give to me,
Bye, Stefano.


Hi Mike,
let me ask to you just a last thing.

Do you know how to automatic update that formula?
I mean, without hit enter every time, on the cell where I insert the
function.

Bye, Stefano.


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default count comments funtion

On Jan 10, 1:56 pm, wrote:
On Jan 10, 1:27 pm, Mike H wrote:



Hi,


Sending a range to it looks simpler
call with
=CommentCount(A1:a100)
Not it must be inserted in a module


Public Function CommentCount(MyRange As Range)
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In MyRange
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


" wrote:
Hi to everyone,
does anyone to know how to build a function, not a macro, to count the
number of comments in a cells range?


searching to this news group I found this code:


Public Function CommentCount()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatile
On Error Resume Next
For Each cell In Selection
Set cmt = Nothing
Set cmt = cell.Comment
If Not cmt Is Nothing Then
cnt = cnt + 1
End If
Next cell
CommentCount = cnt
End Function


but it doesn't seem to work for me. Can someone help me?


I really do appreciate who will give to me an hand
Bye,Stefano.


Hi Mike,
now it works very well!

Many many thanks for the great help you give to me,
Bye, Stefano.


Hi Mike,
let me ask to you just a last thing.

Do you know how to automatic update that formula?
I mean, without hit enter every time, on the cell where I insert the
function.

Bye, Stefano.
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default count comments funtion

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
  #13   Report Post  
Posted to microsoft.public.excel.programming
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.
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
excel 2000 how to format the comments font all comments Delquestion Excel Discussion (Misc queries) 1 October 8th 09 02:19 PM
Count funtion in Pivot Table Aussie Mick F Excel Discussion (Misc queries) 3 February 7th 07 09:47 AM
count comments Jakobshavn Isbrae Excel Discussion (Misc queries) 2 January 8th 07 03:15 PM
Formula format for Count or Countif funtion with two criterias Debi Excel Worksheet Functions 2 September 26th 05 08:23 PM
Count Comments Mr Anthony Griffiths Excel Worksheet Functions 1 November 4th 04 04:20 PM


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