VBA ClearComments in Excel Explained with Examples

We can use VBA to Clear only the Comments of a specific range, cells or entire worksheet. we can use ClearComments method of Range Object. Rang.ClearComments method will clear only the comments in a range. And the data, formats like border, font styles, background cell will remain same and will not be disturbed.



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 ClearComments Method Excel Range Object

Excel VBA to ClearComments a Range – Syntax

Here is the syntax to clear the comments in a range. You can clear the comments in any range or cells using VBA Range.ClearComments method.


Excel VBA to ClearComments in a Range – Examples

The below macro will show you how to clear the comments in a range using VBA. In this example, we are clearing the comments in range “A2 to D10” using VBA.

Sub VBA_Clear_Comments_Range()
End Sub

Excel VBA to Clear Comments in a Range – Instructions

Please follow the below step by step instructions to execute the above mentioned VBA macros or codes:

  1. Open an Excel Workbook from your start menu or type Excel in your run command
  2. Enter some data in any cells in range “A10 to D10” to test this macro. Also format some cell and insert some comments for testing purpose.
  3. Press Alt+F11 to Open VBA Editor or you can go to Developer Table from Excel Ribbon and click on the Visual Basic Command to launch the VBA Editor
  4. Insert a Module from Insert Menu of VBA
  5. Copy the above code (for clearing the comments in a range using VBA) and Paste in the code window(VBA Editor)
  6. Save the file as Macro Enabled Workbook (i.e; .xlsm file format)
  7. Press ‘F5′ to run it or Keep Pressing ‘F8′ to debug the code line by line.

Now you can observe that the comments in the range “A2 to D10” are cleared. You can apply any formats and background color, and try this macro. This will clear only the comments. And formats and the data will be remained same.

If you want to clear everything including formats and data, you can use Range.Clear method, to clear the data in a range you use the Range.ClearContents method.

Range.ClearComments: Will clear only the comments. And the data and formats of the range will remain then same.
Range.ClearContents: Will clear only the content/data of the range, formats will remain same.
Range.Clear: Will clear the data including cell formats.


Leave A Comment

Related pages

excel 2010 stacked bar chartexcel macro rowsaccess macro run queryaccess vba filesystemobjectexcel copy worksheetexcel vba end of columnexcel vba statementsinserting pivot table in excel 2010recording macrosexcel vba color indexsql test questions and answers pdfsecure excel spreadsheetddl queries in sqldelete columns vbavlookup in excel step by stepvlookup explanationexcel test for beginnersexcel 2010 macro securityms excel shortcut keyssql copy recordvb 6.0 interview questions and answers pdfhow to insert a textbox in excelword vba userformgantt chart project plan excel templateshow developer tab in excel 2010excel macro cellssimple cut and paste worksheetsmerge excel files macroexcel application getopenfilenamechart wizard excel 2010access macro tutorialfor loops in vbagantt chart template word 2010vba macros in excel 2007vba user formsvba interview questions and answershow to put a checkbox in excelhow do i insert rows in excelexcel 2007 create drop down listhow to unprotect sheet without passwordexcel csv converterhow to delete empty cellsmultiple if statements in excel formulaexcel project management tracking templatesmsgbox exampleexcel iserrexcel macros for dummiesvba cell addressexcel progress bar vbavba select case examplesql basic commands with examplesexcel conditional statementcosting spreadsheet templatecolor by code worksheetsrca format in wordfilesystemobject movefileexcel conditional vlookuphow to unlock protected cells in excelhow to put countif formula in excelgantt chart excel 2003excel 2010 unhide allhow do i check for duplicates in excelexcel macro activecelllookup in ms excelunlock spreadsheet without passwordexcel remove duplicate recordsexcel formula shortcutswhat is the countif function in excelvlookup vs hlookupexcel vba undohr interview questions indiabixexcel remove macrosms access macros tutorialbuilding dashboards in exceltcl commandsusing worksheet functions in vbaactivate sheet vbapivot table explained