REAL-TIME

VBA Projects

Full Access with Source Code

  • Designed and Developed by PNRao

  • Full Access with VBA Source Code

  • Well Commented Codes Lines

  • Creative and Professional Design

120+ PROFESSIONAL

Project Management Templates

120+ PM Templates Includes:
  • 50+ Excel Templates

  • 50+ PowerPoint Templates

  • 25+ Word Templates

Effortlessly Manage Your Projects

Seamlessly manage your projects with our powerful & multi-purpose templates for project management.

Share Post

VBA Clear Range in Excel will Clear a specific range or entire worksheet using Clear method of Range Object. ‘Rang.Clear’ method will clear the range including the formats like border, font styles, background cell and set to default.

VBA Clear Method Excel Range Object

Excel VBA to Clear a Range – Syntax

Here is the syntax to clear a range. You can clear the data in any range including formats using VBA ‘Range.Clear’ method.

Range(“YourRange”).Clear

Excel VBA to Clear a Range – Examples

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

Sub VBA_Clear_Range()
    Range("A2:D10").Clear
End Sub

Excel VBA to Clear 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.
  3. 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
  4. Insert a Module from Insert Menu of VBA
  5. Copy the above code (for clearing the 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 data in range “A2 to D10” is clear. You can apply any formats and background color, and try this macro. This will clear everything and set to the default.

If you want to clear only the data you can use Range.ClearContents method, to clear the comments in a range you use the Range.ClearComments method.

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

Effortlessly Manage Your Projects and Resources
120+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

Save Up to 85% LIMITED TIME OFFER
Project Management Templates

All-in-One Pack
120+ Project Management Templates

Essential Pack
50+ PM Templates

Excel Pack
50+ Excel PM Templates

PowerPoint Pack
50+ Excel PM Templates

MS Word Pack
25+ Word PM Templates

Ultimate Project
Management Template
Ultimate Resource
Management Template
Project Portfolio
Management Templates
Last Updated: March 2, 2023

2 Comments

  1. Jorge November 1, 2018 at 2:32 PM - Reply

    I would like to clear every second row for which I have a counter:

    Dim counter As Integer
    With ActiveSheet
    For counter1 = 12 To 130 Step 2

    ‘ Delete every second row in column 3
    .Cells(counter1, 3).Clear <— OK

    Next counter
    End With

    So the problem is referencing a range of contiguous cells using a counter. I would be much obliged if you would like to share your expertise here.

  2. EA April 18, 2020 at 6:34 PM - Reply

    Sub delete_alternate_row()

    Dim i As Integer
    Const StartCell As Byte = 10
    Dim EndCell As Long

    EndCell = Range(“H” & StartCell).End(xlDown).Row
    Debug.Print EndCell

    For i = StartCell To EndCell Step 2
    Range(“H” & i).ClearContents

    Next i
    End Sub

Leave A Comment