Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Inserting Workbook Comments Into a Cell.
Written by Allen Wyatt (last updated August 12, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021
Jim would like to insert the text found in the Comments portion of a workbook's properties into a cell. This isn't a comment attached to a cell, but the contents of the Comments field in the workbook properties.
If you need to simply copy the comments a single time, then doing so manually may be the best bet. You can display the Comments field, select whatever contents you want to put into your worksheet, and then press Ctrl+C. Close the properties, select the desired cell, and then press Ctrl+V.
If you have more of a need for the inclusion to be dynamic, then the only way to add those comments to a cell is to use a macro. If you want to have the contents appear in a specific cell (such as A1), then you can simply use a single line of code:
Range("A1")=ActiveWorkbook.BuiltinDocumentProperties("comments")
That's it; a single line of code to stuff the comments into the cell. You can build upon this, if desired, to create a user-defined function that is helpful for placing the comments anywhere you desire.
Function putComments() As String Application.Volatile putComments=ActiveWorkbook.BuiltinDocumentProperties("comments") End Function
In order to use this user-defined function, simply use the following in a cell:
=putComments()
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12333) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Inserting Workbook Comments Into a Cell.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
When formatting comments, you can use a graphic as a background for the comment box. If you later want to move this ...
Discover MoreAdding comments or notes to the cells in your worksheets can help to document different aspects of that worksheet. Adding ...
Discover MoreHave you ever chosen to edit a comment, only to find that the comment is quite a ways from the cell with which it is ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2023-10-03 15:10:42
J. Woolley
My latest comment below describes the SetDocProperty and ListDocProperties functions. My Excel Toolbox now includes the following function to return the value of a workbook's built-in or custom document property:
=GetDocProperty(Name, [Approx])
Alphabetic case of Name is ignored. If optional Approx is FALSE (default), then Name is considered explicit; otherwise, the value of the first document property containing Name is returned. A logical, date/time, or error value will be returned as equivalent text; any other number is returned as a number.
Each worksheet can have custom properties independent of a workbook's custom properties. My Excel Toolbox includes the following functions to set or return the Value of a custom worksheet property:
=SetCustomWSProperty(Name, Value, [Sheet], [Delete])
=GetCustomWSProperty(Name, [Sheet])
Name's case is ignored if custom worksheet property Name exists; otherwise, its case is retained when the new Name/Value pair are added using SetCustomWSProperty. Value is always converted to equivalent logical, date/time, numeric, error, or other text and returned as text.
If optional Sheet is omitted, the custom property applies to the formula cell's worksheet; otherwise, it applies to the specified Sheet (case ignored) in that cell's workbook.
Delete is optional; default is FALSE. If Delete is TRUE, then Value is ignored and custom worksheet property Name (case ignored) is deleted.
The following dynamic array function lists any custom worksheet properties:
=ListCustomWSProperties([AllSheets], [SkipHeader])
If AllSheets is FALSE (default), only the formula cell's worksheet will be evaluated; otherwise, all worksheets in the workbook are included.
If SkipHeader is FALSE (default), a header will be returned in the first row; otherwise, there will be no header row.
The SpillArray function (described in UseSpillArray.pdf) simulates a dynamic array in older versions of Excel.
See https://sites.google.com/view/MyExcelToolbox
2023-08-21 11:09:36
J. Woolley
My Excel Toolbox includes the following function to set the text, numeric, logical, date/time, or error value of a workbook's document property and return confirmation:
=SetDocProperty(Name, Value, [AsDate], [Delete])
If built-in or custom document property Name exists, it will be set to Value; otherwise, a new custom document property Name will be added and set to Value.
If AsDate is TRUE, Value will treated as date/time; default is FALSE.
If Delete is TRUE, custom document property Name will be deleted; default is FALSE. A built-in document property cannot be deleted.
For example, the following formula will set the Comments built-in document property:
=SetDocProperty("Comments","This is my newest version.")
And this formula will add or update a custom document property:
=SetDocProperty("Latest revision","8/20/23 4:15 pm",TRUE)
The following dynamic array function lists built-in and custom (if any) document properties with 2 columns and N rows:
=ListDocProperties([SkipNull], [SkipCustom], [SkipHeader])
There are currently 34 built-in document properties in an Excel workbook.
The SpillArray function (described in UseSpillArray.pdf) simulates a dynamic array in older versions of Excel.
See https://sites.google.com/view/MyExcelToolbox
2023-08-14 14:32:36
J. Woolley
@Peter
As you notiiced in the Tip's title, it is about workbook comments, not worksheet comments.
My Excel Toolbox includes the following function to return the text of a comment associated with a Target worksheet cell:
=CommentText(Target,[SkipAuthor])
This works with either a legacy unthreaded comment (Note) or a threaded Comment. If SkipAuthor is FALSE (default), the comment's author will be included in the returned text if available; otherwise, the comment's author will be removed if possible. If Target is a multi-cell range, its top-left cell applies. If Target's cell does not have a comment, #VALUE! (Error 2015) will be returned.
The following dynamic array function is also included:
=ListComments([AllSheets],[Threaded],[SkipHeader])
This returns one row for each comment with the following columns: Worksheet, Cell, Author, Comment (text). It works for threaded or unthreaded comments. In older versions of Excel you can use ListComments with the SpillArray function described in UseSpillArray.pdf.
See https://sites.google.com/view/MyExcelToolbox
2023-08-13 21:23:25
Peter
The macro Allen provide will not display worksheet comments or notes.
Range("A1")=ActiveWorkbook.BuiltinDocumentProperties("comments") just returns an empty cell for my test workbook where I had a collection of Comments and Notes.
What you get by running this code is the Document Comments, that you find in Properties at at File>Info
Of course it is possible to write a macro function to extract comments for a given cell or range of cells either with or without the author's name.
2023-08-12 11:16:39
J. Woolley
Here are three ways to return the Comments field from the active workbook's document properties using functions available in My Excel Toolbox:
=INDEX(ListDocProperties(,,TRUE),5,2)
=VBAResult("ActiveWorkbook.BuiltinDocumentProperties(5)")
=VBAResult("ActiveWorkbook.BuiltinDocumentProperties(""Comments"")")
Notice "Comments" is the 5th item in BuiltinDocumentProperties.
See https://sites.google.com/view/MyExcelToolbox
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments