Sanjib would like to get a count of all the comments in a worksheet. Unfortunately, Excel doesn't include a function that allows you to access this information. You can, however, get the value manually by using this process:
Figure 1. The Go To Special dialog box.
If you want to get the number of comments and place it into a cell, then you need to use a macro to create a user-defined function.
Function CountComments(rCell As Range) Application.Volatile CountComments = rCell.Parent.Comments.Count End Function
This function grabs the value of the Count property for the Comments collection. It is then returned by the function to the worksheet. To use it in your worksheet, enter a formula such as the following:
=CountComments(A1)
The cell address you use in the formula is unimportant; it should simply reference a cell on the worksheet for which you want the count.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12363) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Counting Comments in a Worksheet.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
Comments can be a boon when you want to annotate your worksheets. If you want, you can instruct Excel to print the ...
Discover MoreWhen formatting comments, you can use a graphic as a background for the comment box. If you later want to move this ...
Discover MoreHave you ever chosen to edit a comment, only to find that the comment is quite a ways from the cell with which it is ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-05-06 01:50:12
HARISH GUPTA M.R
'Codes to count no of comments in a activesheet
Function CountComments1()
CountComments1 = ActiveSheet.Comments.Count
End Function
'Codes to count no of comments in a range
Function CountComment2(rCell As Range)
Dim cl
On Error Resume Next
CountComment2 = 0
For Each cl In rCell
If cl.Comment.Shape.Top < 0 Then
Else
CountComment2 = CountComment2 + 1
End If
Next cl
On Error GoTo 0
End Function
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2022 Sharon Parq Associates, Inc.
Comments