Export Excel Cell Comments to a Text File with VBA
Question details
Export comments from multiple Excel cells along with their cell addresses to a text file.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains hundreds of cell comments that would be time-consuming to copy manually.
- Observed behavior
- The user wants a text file listing each comment and its cell address.
Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) in a folder where you can write files. Check that the worksheet contains legacy comments, called Notes in newer Excel versions, and enable macros only if you trust the workbook.
Export legacy comments from the active Excel worksheet
Use this macro to write each legacy comment and its cell address to a text file in the workbook folder.
The macro exports legacy comments from the active worksheet only. It does not export modern threaded comments.
In Excel, select Developer > Visual Basic. On Windows, you can also press Alt+F11.
In the VBA editor, select the target workbook, choose Insert > Module, and paste this code: Sub ExportComments() Dim c As Comment Dim fileNumber As Integer Dim outputPath As String If ThisWorkbook.Path = "" Then MsgBox "Save this workbook before exporting comments." Exit Sub End If outputPath = ThisWorkbook.Path & Application.PathSeparator & "Test.txt" fileNumber = FreeFile Open outputPath For Output As #fileNumber For Each c In ActiveSheet.Comments Print #fileNumber, c.Parent.Address(False, False) & ": " & c.Text Next c Close #fileNumber MsgBox "Export saved to: " & outputPath End Sub
Return to Excel, select the worksheet containing the comments, and choose Developer > Macros. Select ExportComments and click Run.
Open Test.txt in the folder containing the workbook and check the exported cell addresses and comment text. If the file is empty, verify that the selected worksheet contains legacy comments or Notes.

Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface, making it easy to move everyday workbook tasks from Microsoft Office. It does not fix Excel's VBA export or guarantee that Excel macros will run unchanged.

Frequently Asked Questions
Why is the exported text file empty?
The macro reads legacy comments from the active worksheet. Select the correct sheet and check whether its annotations are Notes rather than modern threaded comments.
Where does the macro save the exported comments?
It saves Test.txt in the folder containing the workbook that holds the macro. Save that workbook first and make sure you can write to its folder.
Can this macro export comments from every worksheet?
Not as written. It uses ActiveSheet.Comments, so select a worksheet and run it for that sheet. Running it again replaces Test.txt unless you change the output file name.
How do I keep the macro in my workbook?
In Excel, use File > Save As and choose Excel Macro-Enabled Workbook (.xlsm). Enable macros when opening the file only if you trust its source.




