• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Working With Comments in VBA

You are here: Home / Excel VBA / Working With Comments in VBA
working with comments in vba
August 1, 2019 by Philip Treacy

To start with let's understand that I'm talking about the 'old' style comments like the one on the left.

In Office 365 we now have Threaded Comments which are also being referred to as comments, with the old style comments being referred to as Notes in O365.

But if you are not using O365 then you will still be using the old style comments and still calling them comments. That's not confusing now is it!

Download Example Workbook

Examples of all the code in this post can be downloaded from the sample workbook

Enter your email address below to download the workbook.

By submitting your email address you agree that we can email you our Excel newsletter.
Please enter a valid email address.

Download the Excel Workbook. Note: This is a .xlsm file please ensure your browser doesn't change the file extension on download.

The Comment Object

To work with comments in VBA you'll be mostly using the comment object.

This allows you to do things like delete a comment, change the comment text, or find out things like the comment author or the cell where the comment is.

Adding a Comment

To add a comment you actually use the AddComment method of the Range object

Add a comment

Note: Creating a comment this way results in a comment without the author's name appearing as it would if you inserted the comment manually.

Delete a Comment

Use the Delete method on the comment.

delete a comment

Deleting Specific Author's Comments from Sheet

You can specify the author by passing a string parameter when you call the Sub, rather than hard code the author.

Delete author's comments

Deleting all Comments on a Sheet

You can specify the author by passing a string parameter when you call the Sub, rather than hard code the author.

deleting all comments in sheet

Deleting all Comments in the Workbook

Loop through every comment, on every sheet

deleting all comments in workbook

Find Comments by Author

This will change the color of the cells where a comment exists from the specified author.

find comment by author

Show or Hide Comment Indicator

Comment Indicator Only

comment indicator only

comment indicator only on sheet

Comment and Indicator

comment and indicator

comment and indicator on sheet

No Indicator

no indicator

no indicator on sheet

Change the Background Color of the Comment

Change comment background to green.

changing comment color

green comment color

List All Comments in Workbook

This routine will create a sheet called Comments and then list every comment from every sheet on it.

list all comments in workbook

You can get this code by downloading the example workbook from the top of the post.

working with comments in vba

More Excel VBA Posts

Display All Matches from Search in Userform ListBox

Display All Matches from Search in Userform ListBox

Search a range for all partial and full matches of a string, and display matching records (entire rows) in a userform listbox. Sample code and userform.
animating excel charts

Animating Excel Charts

Use animation correctly to enhance the story your data is telling. Don't animate your chart just for some eye candy. Sample code and workbook to download.
dynamic data validation lists in userforms

Dynamic Data Validation Lists in Userforms

Data validation lists using the same source that are dynamically modified to prevent the same choice being made in each list.
show report filter pages for power pivot pivottables

Show Report Filter Pages for Power Pivot PivotTables

PivotTables created from Power Pivot can't use the 'Show Report Filter Pages' option. But this piece of VBA allows you to do just that.
charting real time data in excel

Charting Real Time Data in Excel

Receive data in real time and chart the data as it arrives. Can be used to chart things like stock prices or sensor readings. Sample code and workbook
select multiple items from drop down data validation list

Select Multiple Items from Drop Down (Data Validation) List

Choose multiple items from a data validation (drop down) list and store them all in the same cell. Sample workbook with working VBA.
Excel Calendar (Date Picker) to Use in Worksheets and Userforms

Multi-Language Excel Calendar (Date Picker) for Worksheets and Userforms

Easy to use, highly customizable and multi-language. This date picker is implemented as a userform that is simple to integrate into your workbook.
automating and emailing pivot table reports

Automating and Emailing Pivot Table Reports

Automate the creation and distribution of pivot table reports with some VBA. Send reports to multiple email recipients using Outlook.
search for data with userform

Searching for Data With a User Form

Search a list of records (like a table) using a user form, and then populate the fields of the search form when the record is found.
Checking values in range objects with vba

Checking Values in Range Objects With VBA

Use built in tools or your own code to examine the values contained within Range objects in VBA. Sample code to download.


Category: Excel VBA
Previous Post:Find last occurrence of a string in another stringFind the Last Occurrence of a String In Another String
Next Post:Excel Bar Chart with Vertical LineExcel Bar Chart with Vertical Line

Reader Interactions

Comments

  1. J. Woolley

    June 1, 2020 at 6:13 am

    You might be interested in my macros to format, resize, and reposition unthreaded cell Comments (now called Notes). See my web site at https://sites.google.com/view/MyExcelToolbox/
    Achieving a satisfactory resize method was particularly difficult.

    Reply
    • Philip Treacy

      June 26, 2020 at 10:28 am

      Thanks

      Reply
  2. uttam kumar sarker

    November 25, 2019 at 12:55 am

    Awesome post!!!
    Very informative, all the tips you discussed in post are valuable.

    Reply
  3. Matthias

    August 7, 2019 at 10:13 am

    Hi Phil,

    Probably not many people will care about comments, so I would like to let you know that this is nevertheless a really nice and inspiring post. I like the idea of listing all comments as this opens quite a lot of further possibilities of changing, formatting or deleting specific comments.

    I did not understand the purpose of the Debug.Print section (probably just for counting occurrences). But I thought it would make sense to reduce the possibility that any random colon somewhere in the comment would truncate the listed comment:
    If InStr(Comment_.Text, “:”) = InStr(Comment_.Text, Chr(10)) – 1 Then …

    Thanks!

    Reply
    • Philip Treacy

      August 8, 2019 at 9:00 pm

      Thanks Matthias.

      The Debug.Print statement is only there for me for testing, I forgot to comment it out.

      Phil

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Current ye@r *

Leave this field empty

Sidebar

More results...

Featured Content

  • 10 Common Excel Mistakes to Avoid
  • Top Excel Functions for Data Analysts
  • Secrets to Building Excel Dashboards in Less Than 15 Minutes
  • Pro Excel Formula Writing Tips
  • Hidden Excel Double-Click Shortcuts
  • Top 10 Intermediate Excel Functions
  • 5 Pro Excel Dashboard Design Tips
  • 5 Excel SUM Function Tricks
  • 239 Excel Keyboard Shortcuts

100 Excel Tips and Tricks eBook

Download Free Tips & Tricks

Subscribe to Our Newsletter

Receive weekly tutorials on Excel, Power Query, Power Pivot, Power BI and More.

We respect your email privacy

Guides and Resources

  • Excel Keyboard Shortcuts
  • Excel Functions
  • Excel Formulas
  • Excel Custom Number Formatting
  • ALT Codes
  • Pivot Tables
  • VLOOKUP
  • VBA
  • Excel Userforms
  • Free Downloads

239 Excel Keyboard Shortcuts

Download Free PDF

Free Webinars

Excel Dashboards Webinar

Watch our free webinars and learn to create Interactive Dashboard Reports in Excel or Power BI

Click Here to Watch Now

mynda treacy microsoft mvpHi, I'm Mynda Treacy and I run MOTH with my husband, Phil. Through our blog, webinars, YouTube channel and courses we hope we can help you learn Excel, Power Pivot and DAX, Power Query, Power BI, and Excel Dashboards.

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk – For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.