Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default COUNTIF to count cells that have an attached comment

Can I use COUNTIF (or anything) to count the number of cells in a range that
have a comment attached to the cell?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default COUNTIF to count cells that have an attached comment

No, you need VBA

Public Sub Test()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
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
MsgBox cnt
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stonewall Rubberbow" wrote
in message ...
Can I use COUNTIF (or anything) to count the number of cells in a range

that
have a comment attached to the cell?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default COUNTIF to count cells that have an attached comment

Bob, thanks for the quick reply. I'm familiar with Excel, but not how to add
VBA, or what to do with the formula once it has been added. I tried to copy
your post, and paste it into the sheet's code window in Visual Basic, but I
don't know what to do next, or how this affects the worksheet. Can you walk
me through this a little bit?

"Bob Phillips" wrote:

No, you need VBA

Public Sub Test()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
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
MsgBox cnt
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stonewall Rubberbow" wrote
in message ...
Can I use COUNTIF (or anything) to count the number of cells in a range

that
have a comment attached to the cell?




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default COUNTIF to count cells that have an attached comment

After pasting it in a code module, go back to Excel, select a range of
cells, then Alt-F8, select Test from the list, and hit run. You should get a
message telling you how many.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stonewall Rubberbow" wrote
in message ...
Bob, thanks for the quick reply. I'm familiar with Excel, but not how to

add
VBA, or what to do with the formula once it has been added. I tried to

copy
your post, and paste it into the sheet's code window in Visual Basic, but

I
don't know what to do next, or how this affects the worksheet. Can you

walk
me through this a little bit?

"Bob Phillips" wrote:

No, you need VBA

Public Sub Test()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
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
MsgBox cnt
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stonewall Rubberbow"

wrote
in message ...
Can I use COUNTIF (or anything) to count the number of cells in a

range
that
have a comment attached to the cell?






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default COUNTIF to count cells that have an attached comment

Thanks, that does work. What I would ultimately like for it to do is place
the result in a cell, so I don't have to run it. Is there any solution for
that?

"Bob Phillips" wrote:

After pasting it in a code module, go back to Excel, select a range of
cells, then Alt-F8, select Test from the list, and hit run. You should get a
message telling you how many.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stonewall Rubberbow" wrote
in message ...
Bob, thanks for the quick reply. I'm familiar with Excel, but not how to

add
VBA, or what to do with the formula once it has been added. I tried to

copy
your post, and paste it into the sheet's code window in Visual Basic, but

I
don't know what to do next, or how this affects the worksheet. Can you

walk
me through this a little bit?

"Bob Phillips" wrote:

No, you need VBA

Public Sub Test()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
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
MsgBox cnt
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stonewall Rubberbow"

wrote
in message ...
Can I use COUNTIF (or anything) to count the number of cells in a

range
that
have a comment attached to the cell?








  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default COUNTIF to count cells that have an attached comment

Make it as a UDF

Public Function CommentCount()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
Application.Volatilre
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 Sub

then use =CommentCount() in a cell. Note that it won't automatically update
when comments are added, deleted as these will not trigger recalculation,
but will update on a recalculation, forced or natirally occurring.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stonewall Rubberbow" wrote
in message ...
Thanks, that does work. What I would ultimately like for it to do is place
the result in a cell, so I don't have to run it. Is there any solution for
that?

"Bob Phillips" wrote:

After pasting it in a code module, go back to Excel, select a range of
cells, then Alt-F8, select Test from the list, and hit run. You should

get a
message telling you how many.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stonewall Rubberbow"

wrote
in message ...
Bob, thanks for the quick reply. I'm familiar with Excel, but not how

to
add
VBA, or what to do with the formula once it has been added. I tried to

copy
your post, and paste it into the sheet's code window in Visual Basic,

but
I
don't know what to do next, or how this affects the worksheet. Can you

walk
me through this a little bit?

"Bob Phillips" wrote:

No, you need VBA

Public Sub Test()
Dim cell As Range
Dim cnt As Long
Dim cmt As Comment
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
MsgBox cnt
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stonewall Rubberbow"

wrote
in message

...
Can I use COUNTIF (or anything) to count the number of cells in a

range
that
have a comment attached to the cell?








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
Count cells with numbers and ignore cells with errors WonderingaboutMicrosoft Excel Discussion (Misc queries) 6 December 10th 06 08:03 PM
How to count blank cells that contain formula? IntricateFool Excel Discussion (Misc queries) 5 June 8th 06 02:45 PM
How to count interstitial blank cells? [email protected] Excel Discussion (Misc queries) 3 April 16th 06 03:53 AM
Formula format for Count or Countif funtion with two criterias Debi Excel Worksheet Functions 2 September 26th 05 08:23 PM
Count number of shaded cells Maddoktor Excel Discussion (Misc queries) 2 December 20th 04 08:35 PM


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