How to Make Notes in VBA (Excel)

VBA & macros · Updated November 23, 2026

This guide shows you how to create, read, and manage notes (also called cell comments) in Excel using VBA. With a few lines of code, you can add a note to a cell, retrieve its text, update it, or delete it—all without touching the mouse. You’ll need a workbook with some data and the Visual Basic Editor (VBE), which is built into Excel.

What You’ll Need

  • Microsoft Excel (2016, 2019, 2021, or Microsoft 365) on Windows. Steps are similar on Mac, but the VBE shortcut differs.
  • A workbook with at least one worksheet containing data. For the examples, we’ll use cells A1 and B1.
  • Basic familiarity with the VBA editor (opening it, inserting a module).

Step-by-Step

  1. Open the Visual Basic Editor. Press Alt + F11 on Windows (on Mac, Fn + Option + F11). If you’re in Excel for the web, VBA is not supported—use the desktop version.
  2. Insert a module. In the VBE, go to Insert > Module. This creates a blank code window where you’ll write your macros.
  3. Write a macro to add a note. Type the following code into the module. This adds a note to cell A1 on the active sheet.
    Sub AddNote()
        ' Adds a note to cell A1
        Dim ws As Worksheet
        Set ws = ActiveSheet
        
        ' Remove any existing note first
        ws.Range("A1").ClearNotes
        
        ' Add the note with text
        ws.Range("A1").AddComment "This is a note."
    End Sub

    Run it by pressing F5 while the cursor is inside the macro. You’ll see a red triangle on A1; hover to see the note.

  4. Read a note’s text. To retrieve the text from a note, use the Comment property. This macro displays the note in a message box.
    Sub ReadNote()
        Dim ws As Worksheet
        Set ws = ActiveSheet
        
        Dim noteText As String
        If ws.Range("A1").Comment Is Nothing Then
            noteText = "No note exists."
        Else
            noteText = ws.Range("A1").Comment.Text
        End If
        MsgBox noteText
    End Sub
  5. Edit an existing note. The Comment.Text property can be set. This macro changes the note on A1 to a new text.
    Sub EditNote()
        Dim ws As Worksheet
        Set ws = ActiveSheet
        
        ' Check if note exists
        If ws.Range("A1").Comment Is Nothing Then
            MsgBox "No note to edit. Add one first."
        Else
            ws.Range("A1").Comment.Text "Updated note text."
        End If
    End Sub

    Note: When setting .Text, you must pass the new text as an argument, not assign it directly.

  6. Delete a note. Use ClearNotes to remove all notes from a range, or Delete on the comment object.
    Sub DeleteNote()
        Dim ws As Worksheet
        Set ws = ActiveSheet
        
        ' Deletes only the note on A1
        If Not ws.Range("A1").Comment Is Nothing Then
            ws.Range("A1").Comment.Delete
        End If
    End Sub
  7. Loop through all notes on a sheet. This macro lists every cell that has a note and its text.
    Sub ListAllNotes()
        Dim ws As Worksheet
        Set ws = ActiveSheet
        
        Dim cmt As Comment
        Dim output As String
        
        For Each cmt In ws.Comments
            output = output & cmt.Parent.Address & ": " & cmt.Text & vbNewLine
        Next cmt
        
        If output = "" Then
            MsgBox "No notes found."
        Else
            MsgBox output
        End If
    End Sub

    Here, cmt.Parent returns the range that the comment is attached to.

  8. Add a note with author name. The AddComment method uses the current Windows username. To set a custom author, you can modify the Author property after adding.
    Sub AddNoteWithAuthor()
        Dim ws As Worksheet
        Set ws = ActiveSheet
        
        ws.Range("B1").ClearNotes
        ws.Range("B1").AddComment "Review this."
        ws.Range("B1").Comment.Author = "Analyst"
    End Sub

Common Mistakes

  • Forgetting to clear existing notes before adding. If a cell already has a note, AddComment will raise an error. Always use ClearNotes or check if Comment Is Nothing.
  • Using .Text incorrectly. To set text, you must call Comment.Text "new text"—not assign like Comment.Text = "new text". The latter causes a compile error.
  • Assuming notes are the same as threaded comments. In Excel 365, there are two types: legacy notes (this article) and threaded comments (introduced later). VBA’s Comment object works only with legacy notes. Threaded comments require a different object model (not covered here).
  • Running macros without saving a backup. VBA actions cannot be undone with Ctrl+Z. Always save a copy of your workbook before running any macro that modifies data or notes.

Tips

  • Use ClearNotes on a whole range to remove multiple notes at once. For example, ws.Range("A1:C10").ClearNotes.
  • Check for existing notes with If Not rng.Comment Is Nothing. This avoids errors and is faster than relying on error handling.
  • To add a note to a cell with a formula, the note is independent of the formula. You can add notes to any cell, even if it contains a value or formula.
  • Notes are stored with the workbook. When you share the file, others can see the notes. If you want to hide them, use Application.DisplayCommentIndicator = xlNoIndicator (or set the sheet’s DisplayComments property).
  • Use the Comment.Shape property to adjust the note’s size or position. For example, rng.Comment.Shape.Width = 200 sets the width in points.

Troubleshooting

  • “Run-time error 1004: Application-defined or object-defined error” when adding a note: The cell already has a note. Use ClearNotes first, or check with If rng.Comment Is Nothing.
  • “Compile error: Method or data member not found” when using .Text: Ensure you’re using the correct syntax. For setting text, use Comment.Text "..." (not =). For reading, Comment.Text works fine.
  • Notes not visible even after adding. Check if comments are hidden in the workbook. Go to File > Options > Advanced and under Display, select “Indicator and comments on hover” or “Comment indicator only”.
  • Macro works in one sheet but not another. Ensure the sheet is active or explicitly reference the sheet by name, e.g., ThisWorkbook.Worksheets("Sheet1") instead of ActiveSheet.
  • When using For Each cmt In ws.Comments, it doesn’t find any comments. Make sure the comments are legacy notes, not threaded comments. Threaded comments are not part of the Comments collection.

Frequently Asked Questions

  • Can I add a note to a cell without using VBA? Yes, you can manually right-click a cell and choose “New Note” (or “Insert Comment” in older versions). VBA automates this for many cells at once.
  • What’s the difference between a note and a comment in Excel? In Excel 365, “notes” are the legacy yellow sticky notes, while “comments” are threaded discussions. VBA’s Comment object refers to notes. Threaded comments are accessed differently.
  • Can I make a note automatically appear when a cell changes? Yes, you can use the Worksheet_Change event to add a note when a cell’s value changes. For example, add a note with the timestamp.
  • How do I remove all notes from an entire workbook? Loop through all worksheets and use Cells.ClearNotes on each sheet. Example: For Each ws In ThisWorkbook.Worksheets: ws.Cells.ClearNotes: Next ws.
  • Can I export notes to a separate text file? Yes, you can loop through the Comments collection and write the cell address and text to a text file using Open and Print # statements.
  • Why does my note show the wrong author? The author is taken from your Windows username by default. To change it, set the Comment.Author property after adding the note.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.