|
|
|
|
|
|
Excel
|
Check Cell for Comment
|
|
Ease of Use
|
Easy
|
Version tested with
|
2000, 2002
|
Submitted by:
|
Zack Barresse
|
Description:
|
Run this macro to test the current active cell to see if it has a comment.
|
Discussion:
|
Not sure if a specific cell has a comment? Run this user-friendly code to find out.
If you wanted to add a comment to a cell, and that cell already had a comment, your code would error out. Likewise if you tried to edit a comment that didn't exist, your code would error out. This demonstrates a method for checking a cell for the existance of a comment.
|
Code:
|
instructions for use
|
Option Explicit
Sub testCom()
On Error GoTo no1
If Not ActiveCell.Comment.Text = "" Then
MsgBox "Has comment"
End If
Exit Sub
no1:
MsgBox "No Comment"
End Sub
|
How to use:
|
- Copy the code above.
- Open a workbook.
- Hit Alt + F11 to open the Visual Basic Editor (VBE).
- Select your file in left pane, go to Insert -> Module.
- Paste the code into the code window that appears at right.
- Save the file, and close the VBE window.
|
Test the code:
|
- Select a cell with a comment.
- Press Alt + F8, choose testCom.
- Press Run.
- Do the same for a cell without a comment.
|
Sample File:
|
TestComment.zip 6.04KB
|
Approved by mdmackillop
|
This entry has been viewed 234 times.
|
|