VBA Add Comments to Excel Range - Explained with Examples

We can add comments to a range using VBA. When you are automating any task you may wants to write the comments dynamically based on the data. You can use Range.AddComment method to insert a comment to a particular range or a cell. The below example macro codes will show you – how to add or insert comments using VBA in Excel 2003,2007,2010,2013 or higher.



50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates

VBA AddComment Method Excel Range Object

Why we need to add comments using VBA

When we are automating any Excel task or preparing the Excel templates, it is better idea to provide enough information to the user. In some cases, the actual Cell or Range may not be sufficient to show the information, or you may want to show the additional information to the user or client (like instructions, help, or about the field, or you may want to to describe more about some data in a range or cell. Adding comments will be a good idea to provide such information, this will also help your worksheet looks more cleaner as comments will not appear until your user or customer hover on the cell or a range.

VBA Add Comments in an Excel Range – Syntax

You can use the below syntax or Macro Code to add or insert comments to a range in Excel using VBA.

Range(“YourRange”).AddCommnet “Your Text”

VBA to Add Comments in an Excel Range – Examples

Please look into the below examples will show adding comments in different situations while automating your tasks.

VBA to Add Comments in an Excel Range – Simple Example

The below example will show you how to add a comment at Range “A2” as ‘Hello, this is a comment text’:

Range("A2").AddComment "Hello, this is a comment text"

Here AddComment is method of an Excel Range to add the comments. And ‘A’ is the Column Name and ‘2’ is the Row number.

VBA to Add Comments in an Excel Range – Instructions

  1. Open an Excel Workbook from your start menu or type Excel in your run command
  2. Press Alt+F11 to Open VBA Editor or you can goto Developer Table from Excel Ribbon and click on the Visual Basic Command to launch the VBA Editor
  3. Insert a Module from Insert Menu of VBA
  4. Copy the above code for adding or inserting c comment into a range and Paste in the code window(VBA Editor)
  5. Save the file as Macro Enabled Workbook (i.e; .xlsm file format)
  6. Press ‘F5′ to run it or Keep Pressing ‘F8′ to debug the code line by line.

Now you can observe that a new comment is added at Range A2 as “Hello, this is a comment text”.

Real-time Applications on VBA AddComment to a Range Method

Hide Developer Tab in Excel Ribbon

Hide Developer Tab in Excel Ribbon using from the Excel options. It helps to prevent users from opening the Excel VBA editor window. Hide Developer Tab in Excel Ribbon: Right click on any main menu

  • Excel UserForm show hide unload

Show or Hide|Unload a userform

Show or hide means to display or hide a Userform. We use Show and Hide methods to display or hide. Unload will be used when completes the task.

  • Column Number to Column Name

Column Number to Column Name

Column Number to Column Name is nothing but converting column number to Excel alphabetic character column name. Most of the time while automating many tasks using Excel VBA, it may be required.

  • Column Number to Column Name

Column Name to Column Number

Column Name to Column Number is nothing but converting Excel alphabetic character column name to column number. Most of the time while automating many tasks it may be required. Please find the following details about conversion of column name to column number. You can also say column string to column number. Or get alphabetic character to column number using Excel VBA.


Leave A Comment

Related pages

vba word tablesexcel 2007 formulas tutorialoffset function in excel 2010advanced excel tutorial pdflearn vba programmingproject management templates for excelcopy sheet excel vbavba msgbox new linedelete duplicates in excel 2003macros on excelvba interior coloraddress vba excelwhere to find pivot table in excel 2010data control language dclhow do you hide a column in excelmacro to delete duplicate rows in excelms access mcq questions and answers pdfsample vbaexcel combo box vbaexcel formula and operatorvba excel delete columnsvba create graphvba save as dialoghow to insert a row in excelsumif function excel 2010vlookup excel vbaexcel 2010 chart titlemultiple if scenarios in excelvlookup excel 2003fix vbahow to delete hidden rows in excelinsert excel buttonprotect workbook excel 2007excel remove doubleseasy way to find duplicates in excelvba print pdfsteps in creating a chart in excelexcel macro nested ifvba case examplespotfire basicssql interview questions pdf for freshersuse vlookup in vbaconsolidate excel workbookscombobox in excelconnect excel to sqlexcel undo macroexcel vba unprotect workbook without passwordopen excel file using vbaquery table vbaexcel vba sumhow to protect excel from editingexcel vba wait functionfor loop in excel macroexcel macro delete columndim excel vbavba iserrornested if in excel exampleexcel change background color based on valuerange lookup excelvba mailtoexcel macro workbookvba worksheets.addhow to run macros in excelhow to crack excel vba passwordfind duplicates in excellopen a workbook in excel vbavba protect workbooklast cell excelfind duplicates in excelvba msgbox exampleexcel formulas with examples in excel sheethow do i insert rows in excelinserting pivot table in excel 2010excel vba connectionexcel microsexcel templates gantt chartchoose function excelworkbook worksheetshow to merge to columns in excelhow to eliminate duplicates in excelarray functions vbavba message box example3d graphing in excel