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.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!
Excel allows you to use a picture as a background on a cell comment. This tip looks at how you can paste pictures into a ...
Discover MoreWant to make your worksheet comments appear a certain way? It's easy to do using techniques you are already familiar with.
Discover MoreThere are three different ways that Excel allows you to display any comments that are in your worksheet. Here's how you ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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 © 2023 Sharon Parq Associates, Inc.
Comments