How to count number of cells with comments in Excel?
Have you ever tried to count the number of comments in a worksheet? In this article, I will introduce you some quick tricks to count how many cells with comments in a worksheet.
Count number of cells containing comments with Go To Special function
Count number of cells containing comments with User Defined Function
Count number of cells containing comments with VBA code
Count number of cells containing comments with Go To Special function
With the Go To Special feature in Excel, you can select all the comment cells first, and then view the count number in the status bar.
1. Go to click Home > Find & Select > Go To Special, see screenshot:
2. In the Go To Special dialog box, please check Comments option under Select section, see screenshot:
3. Then click OK button to close this dialog, and all the cells in active worksheet which contain the comment have been selected at once. And you can get the count number of the comments at the status bar. See screenshot:
Note: If you have blank cells with comments, the blank cell comments will not be counted.
Tip: You also can press Ctrl + G shortcuts to open Go To dialog, and click Special button to show Go To Special dialog.
Count number of cells containing comments with User Defined Function
The above method has its own disadvantage, so, we can create a User Defined Function to count all the cell comments including the blank cell comments.
1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Count number of cells with comment
Function CountComments(xCell As Range)
'Update 20140924
Application.Volatile
CountComments = xCell.Parent.Comments.Count
End Function
3. Then save and close the code, go back to the worksheet, in a blank cell please enter this formula: =countcomments(A1), (A1 is a cell reference, you can change it to any other cell address ), see screenshot:
4. Then press Enter key, and you will get the number of cell comments.
Count number of cells containing comments with VBA code
The following VBA code also can help you tocount all the cell comments including the blank cell comments.
1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Count number of cells with comment
Sub CountComments()
'Update 20140924
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Set WorkRng = WorkRng.SpecialCells(xlCellTypeComments)
If VBA.Err > 0 Then
MsgBox 0
Else
MsgBox WorkRng.Count
End If
End Sub
3. Then press F5 key to run this code, and a prompt box will pop out to remind you to select a data range that you want to count the cell comments. See screenshot:
4. And then click OK, you will get the number of cell comments in the selection.
Related articles:
How to list all comments to a new worksheet or workbook in Excel?
How to find and replace text within comments in Excel?
How to quickly insert a comment to multiple cells in Excel?
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!