Add Comments in Excel VBA: Notes and Threaded Comments

VBA & macros · Updated November 2, 2026

Add Comments in Excel VBA: Notes and Threaded Comments

To add a cell note with Excel VBA, select the cell and run ActiveCell.AddComment "Check this value." in a macro; Excel calls these older-style annotations notes. For a modern threaded comment in a supported Microsoft 365 version, use ActiveCell.AddCommentThreaded "Can you confirm this figure?". These are different annotation types, so choose the one that fits how the workbook will be used.

Notes and threaded comments in Excel

Excel has two kinds of cell annotations. A note is the traditional annotation that earlier Excel versions called a comment. It is a single block of text attached to a cell, suitable for instructions, explanations, or background information. A threaded comment supports replies and discussion between people. In current Excel, the Review tab and the cell context menu distinguish these options as New Note and New Comment.

VBA’s older Range.AddComment method creates a note, not a reply-enabled discussion. That distinction matters: a macro using AddComment will not create a threaded conversation, even if the workbook is opened in a recent version of Excel. Conversely, AddCommentThreaded is intended for threaded comments and is not available in every Excel release or build.

Also distinguish cell annotations from comments in VBA code. An apostrophe in a VBA module marks a code comment, such as ' Add a note to the selected cell; it does not create anything in the worksheet. To annotate a worksheet cell, the macro must call an Excel object-model method on a Range.

Add a note to the selected cell

This macro adds a note to the currently selected cell. If that cell already has a traditional note, it replaces the note’s text rather than raising an error. It is written for desktop Excel on Windows; the same VBA object-model approach works in desktop Excel for Mac, subject to version support for particular methods.

Before running any macro, save a copy of the workbook. VBA changes cannot be reversed with Ctrl+Z, so keeping a backup is the safest way to recover from an unwanted change.

Sub AddNoteToActiveCell()
    Dim target As Range

    ' Use the selected worksheet cell.
    Set target = ActiveCell

    ' Add a note, or replace the text of an existing note.
    If target.Comment Is Nothing Then
        target.AddComment "Check this value before sending the report."
    Else
        target.Comment.Text "Check this value before sending the report."
    End If
End Sub

To enter and run it on Windows, press Alt+F11 to open the Visual Basic Editor, choose Insert > Module, paste the procedure, and return to the worksheet. Select the destination cell, press Alt+F8, choose AddNoteToActiveCell, and click Run. On Mac, Option+F11 opens the Visual Basic Editor on many keyboards; you may need Fn as well, depending on the keyboard settings. The Mac Developer tab or Tools menu can also be used to access macro tools. Excel for the web cannot create or run VBA macros.

The macro operates on ActiveCell, so check the selected cell before running it. If you want a fixed destination instead, replace the Set line with a worksheet reference such as Set target = ThisWorkbook.Worksheets("Summary").Range("B4"). The worksheet name must match a tab in the workbook. A reference using ThisWorkbook points to the workbook containing the macro, which is usually safer than relying on whichever workbook happens to be active.

Add a threaded comment instead

For a reply-enabled comment, use AddCommentThreaded where the installed Excel version supports it. The following macro adds a new threaded comment to the selected cell:

Sub AddThreadedCommentToActiveCell()
    Dim target As Range

    ' Use the selected worksheet cell.
    Set target = ActiveCell

    ' Add a threaded comment in supported Excel versions.
    target.AddCommentThreaded "Can you confirm this figure?"
End Sub

This method is intended for recent Excel versions with threaded comments, including supported Microsoft 365 desktop builds. Older installations may not expose the method and can return a VBA error. If compatibility with older Excel versions is important, use AddComment to create a note instead. A note does not provide threaded replies, but its broader compatibility can make it a better choice for workbooks shared across mixed versions.

Do not assume that replacing AddComment with AddCommentThreaded is a harmless upgrade. The two methods create different kinds of objects, with different editing and collaboration behavior. If a cell already has an annotation, decide whether the macro should update it, leave it alone, or report it to the user. A simple macro that blindly adds an annotation can fail when a cell already contains one.

Add notes to many cells

For a batch task, a loop can read note text from one column and attach it to the cell beside it. This example reads text from B2:B20 on the Data worksheet and puts it in notes on the corresponding cells in column A. It skips blank source cells and updates an existing traditional note. It assumes those destination cells are appropriate for notes and do not contain threaded comments.

Sub AddNotesFromColumnB()
    Dim ws As Worksheet
    Dim sourceCell As Range
    Dim targetCell As Range
    Dim noteText As String

    ' Set the worksheet that contains the source text.
    Set ws = ThisWorkbook.Worksheets("Data")

    ' Copy each nonblank B-cell value into a note in column A.
    For Each sourceCell In ws.Range("B2:B20")
        noteText = CStr(sourceCell.Value)
        Set targetCell = sourceCell.Offset(0, -1)

        If Len(noteText) > 0 Then
            If targetCell.Comment Is Nothing Then
                targetCell.AddComment noteText
            Else
                targetCell.Comment.Text noteText
            End If
        End If
    Next sourceCell
End Sub

Change the worksheet name and range to fit the workbook. The offset of zero rows and minus one column means the target is immediately to the left of each source cell. If source text is produced by formulas, CStr reads the cell’s displayed value as a string. Test a batch macro on a copy first, especially when the source range is large or the destination cells contain valuable existing annotations.

Show, hide, edit, or remove a note

A note is usually hidden until a user selects or points to its cell, depending on Excel’s display settings. VBA can control visibility for a traditional note through the Comment object. For example, after setting target to a cell, target.Comment.Visible = True displays its note, while setting the property to False hides it. The code will fail if the cell has no traditional note, so test that the Comment property is not Nothing first.

To edit a note, call its Text method, as in the earlier macro. To delete a traditional note, use the note’s Delete method after checking that one exists. Excel’s worksheet interface also provides commands on the Review tab for showing, editing, and deleting notes. The exact labels can vary slightly by update, but New Note, Edit Note, and Delete Note are the relevant commands in current desktop Excel.

Threaded comments have their own objects and collaboration behavior. Do not use the legacy Comment property as though it were a universal way to inspect or edit both annotation types. If your automation must manage threaded comments, check the object-model support in the target Excel version and test it there; a macro written for notes should not be treated as a complete threaded-comment management tool.

Common errors and practical safeguards

  • Method not supported: AddCommentThreaded may not be available in an older Excel build. Use AddComment for a traditional note when compatibility is more important than threaded replies, or update Excel where appropriate.
  • Object variable not set: A cell with no note has no Comment object. Check If target.Comment Is Nothing Then before accessing properties such as Text or Visible.
  • Wrong cell changed: ActiveCell depends on the user’s current selection. Use a fully qualified worksheet and range when the macro must always target a particular cell.
  • Macro will not run: Save a macro-enabled workbook as .xlsm and allow macros only when the workbook and its source are trusted. Excel for the web does not run VBA.
  • Changes cannot be undone: Ctrl+Z does not undo a macro’s worksheet edits. Save a backup before running code that adds, replaces, or deletes annotations.

VBA security is worth considering when a workbook arrives by email or download. Do not enable macros simply to view a cell note; notes can be read without running code. Enable or run VBA only when you trust the workbook’s origin and understand what the macro is intended to change.

Choosing between a macro and Excel’s interface

For a one-off annotation, using Excel’s interface is usually simpler: select a cell, open Review, and choose New Note or New Comment. That avoids enabling macros and makes it easy to type or reply manually. A VBA macro is useful when the same annotation must be inserted repeatedly, when text comes from another range, or when a workbook needs a repeatable workflow.

Use notes for static explanations such as a definition, data source, or reminder. Choose threaded comments when reviewers need to respond to one another or resolve a discussion. If the file will be opened in different Excel releases, consider whether all recipients can use the chosen type and whether preserving a reply thread matters. Excel desktop for Mac supports VBA, but shortcut keys and some feature availability differ by version; Excel for the web does not run VBA, even though it can open many macro-enabled files.

Another practical choice is whether to store information in a cell rather than an annotation. If the text is important data that needs sorting, filtering, searching, or reporting, a dedicated table column is generally more reliable than hiding it in a note. Notes and comments are best for supplementary context, not as a substitute for structured workbook data.

Frequently Asked Questions

Does Range.AddComment create a modern threaded comment?
No. Range.AddComment creates a traditional note. Use Range.AddCommentThreaded in an Excel version that supports threaded comments when you need replies.

How do I add a comment to a specific cell instead of the selected cell?
Set a Range variable to a fully qualified reference, such as ThisWorkbook.Worksheets(“Summary”).Range(“B4”), then call AddComment or AddCommentThreaded on that range. Confirm the sheet name is correct.

Why does my macro say the Comment object is missing?
A cell without a traditional note returns Nothing for its Comment property. Check for Nothing before changing the note’s text, visibility, or other properties.

Can I run a VBA macro in Excel for the web?
No. Excel for the web can work with many workbooks that contain macros, but it does not execute VBA. Open the file in the desktop Excel application to run the macro.

Can Ctrl+Z undo a note added by VBA?
No. Running a VBA macro clears Excel’s normal undo history, so Ctrl+Z cannot reverse the macro’s changes. Save a separate copy before running it.

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.