ID: Q184096
The information in this article applies to:
Microsoft Excel 98 Macintosh Edition no longer uses cell notes; instead, Excel 98 uses cell comments. Consequently, the macro code you use to determine whether a cell contains a comment is different. This article contains information about programmatically determining whether a cell contains a comment and about compatibility with earlier versions of Microsoft Excel.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/
In earlier versions of Microsoft Excel, you can determine whether the active cell contains a cell note by running a macro that is similar to the following example:
Sub Contains_Note()
If ActiveCell.NoteText = "" Then
MsgBox "cell has no note"
Else
MsgBox ActiveCell.NoteText
End If
End Sub
If you run this macro and the active cell does not contain a cell note, a
message box displays a "cell has no note" message.
NOTE: You can successfully run this macro in Microsoft Excel 98 even though all cell notes are converted to cell comments when you open a Microsoft Excel version 5.0 file in Microsoft Excel 98.
To ensure that the macro works in all versions of Microsoft Excel that support Visual Basic for Applications, use a macro that is similar to the example provided in this article.
To ensure future compatibility with Microsoft Excel and specifically with cell comments, you may want to use the Comment property in the Visual Basic macro. In the following macro, the Comment property for a Range object returns a Comment object. If the active cell does not have a comment, the Comment property returns Nothing.
Sub Has_Comment()
Dim mycomment As Comment
Set mycomment = ActiveCell.Comment
If mycomment Is Nothing Then
MsgBox "no comment in cell"
Else
MsgBox mycomment.Text
End If
End Sub
NOTE: The Has_Comment macro does not work in earlier versions of Microsoft
Excel.
For more information about cell comments, from the Visual Basic Editor, click the Office Assistant, type "comment," click Search, and then click to view "Comment Property."
NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q176476
TITLE : OFF: Office Assistant Not Answering Visual Basic Questions
Additional query words: vbe XL98
Keywords : kbprg kbdta kbdtacode xlvbahowto xlvbainfo OffVBA
Version : MACINTOSH:98
Platform : MACINTOSH
Issue type : kbhowto
Last Reviewed: May 18, 1999