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 formula to change cell colorvba do loopshlook upshortcut key for pivot table in excel 2007excel macro querywhat is operator and operandunprotect excel vba codeexcel vba istextexcel how to sort alphabeticallyspreadsheet for project managementvlookup two worksheetshow to dynamically change excel chart datamacros databasehow to insert row on excelexcel vba scriptsvbs rangeexcel vba cells offsetsql search for duplicate valuesexcel vba range cellshow to use multiple if condition in excellearning macrosexcel hlookup tutorialpowerpoint project management templatehow to convert xlsx to xmldata analytics interview questions and answerscool vb scriptsexcel function hlookupexcel macro delete blank rowsmultiple conditions in excelcolour index excelunlock excelshortcut key for insert rowaccess vba basicshow to learn macro in excel 2007cost analysis template excelexcel vba coding tutorialexcel dynamic chartscommonly asked interview questions with answers for freshersdeleting blank cells in excelexcel merge cells with datascreen macro recorderhow to delete blank row in excelhow to eliminate blank rows in excelexcel 2007 delete blank rowsms excel dashboard templatesusing excel vba to run sql queryhow to protect a worksheet in excelvbokcancel vbaexcel shortcut sheetexcel dashboard creatorunhide hidden columns in excelproject portfolio dashboard template excelvba enumerationvba step by step runhow to merge the cells in excelexcel macro formulasexcel chart titlehow to connect excel to sql server databaseunprotect all sheets excelwhere to learn vbamacros in excel 2007 for beginners3d plotting in excelproject charter pptturn on macros in excel 2007match formula in excellookup command in excelvba excel pivot tabledelete row in excel shortcutoffset in excel 2007vlookup excel examplesinterview questions for programmers and answershow to protect cells in excel 2007interview question on c language with answers pdfhow to make macros in excel 2007excel odbc sql queryexcel vba add inssample excel macro programsexcel macro checkboxexcel ctrl endvlookup and hlookup tutorial pdf