Search code examples
excelexcel-formulacomments

Adding a comment as a formula


How to automate a comment on an Excel Sheet? Is there a formula to create a comment like "= Comment("etc")" or else?

For example, In a column with a short introduction about every row, I figured a comment would be better than a long text in every cell.

Other alternatives are welcomed as well.


Solution

  • One simple answer using VBA would be to create a VBA function like this:

    Option Explicit
    
    Function InsertComment(Stringincell As String, StrinComment As String)
       Application.Caller.ClearComments
       Application.Caller.AddComment StrinComment
       InsertComment = Stringincell
    End Function
    

    Now you use your regular excel and enter the function/formula in a cell to get your text as a comment:

    =Comment("String to see in the cell","String you want to see in the comment")