VBA ClearContents / Clear Cells

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on July 21, 2021

In VBA it’s easy to clear cells or cell properties with the .Clear methods.

VBA Clear Cells / Ranges

Type the following into the VBA Editor.

Range("a1").Clear

This will display all of the Clear methods available to you:

vba clear cells

As you can see, You can clear:

  • Everything ( .Clear)
  • Comments ( .ClearComments)
  • Contents ( .ClearContents)
  • Formats ( .ClearFormats)
  • Hyperlinks ( .ClearHyperlinks)
  • Notes ( .ClearNotes)
  • Outline ( .ClearOutline)

VBA ClearContents

The most common clear method is ClearContents. ClearContents clears only the contents of cells (cell values / text). It does not clear formatting, comments, or anything else.

Range("b2").ClearContents

vba clearcontents

ClearContents is the same as pressing the Delete key on your keyboard.

You can also clear the contents of an entire range of cells:

Range("b2:c10").ClearContents

VBA Clear

Clear will clear all cell properties from a cell:

Range("b2").Clear

vba clear

VBA Clear Formatting

To clear cell formatting use ClearFormats

Range("b2").ClearFormats

vba clear formats

Clear Selection

To clear the current selection:

Selection.Clear

Clear Entire Sheet

To clear an entire worksheet:

Sheets("Sheet1").Cells.Clear

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as


Learn More!
vba-free-addin

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)

Free Download

Return to VBA Code Examples