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

Effortlessly
Manage Your Projects

120+ Project Management Templates

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

120+ PM Templates Includes:
  • 50+ Excel Templates

  • 50+ PowerPoint Templates

  • 25+ Word Templates

Share Post

VBA activate range macro code helps you to activate a range in an excel worksheet. You can use the Activate method of Range object to activate any range or one single cell in the worksheet. You can follow this tutorial to know – how to activate a range using VBA in Excel 2003,2007,2010,2013 or above.

VBA Activate Method Excel Range Object

Why we need to activate a Range using VBA?

When we are automating any tasks we can activate a range and perform different tasks with the active range. For example, we can format the background color, font color, font style, font size etc.

VBA Activate Range – Syntax

Here is the example syntax to activate a range using VBA.

Range(“YourRange”).Activate

Usage:The below excel macro will activate range D1.

Range(“D1”).Activate

Here, Activate is the method of Range object. Where D1 is the Range which we want to activate.

VBA Activate Range – Examples

Please see the below VBA codes to activate a Range.

Example 1:Activating one single cell.

The below macro can be used to activate a one single cell. It can be written in two ways. The first one is using Range object and the second statement is using cells object(Range is a collection of cells or one single cell).

Sub Activating_Single_Cell()
    Range("A2").Activate
    'or
    Cells(2, 1).Activate
End Sub

In Range(“A2”).Activate statement ‘A2’ is the range which we are activating. Here, ‘A’ is the column name and ‘2’ is the row number.

In Cells(2, 1).Activate statement ‘2’ is the row number and ‘1’ is the column number.

Example 2:Activating Multiple cells.

The below macro can be used to activate multiple cells. You can mention the start range and end range separated with a colon. For example, To activate a range from A2 to C3, you can mention as Range(“A2:C3”).Activate. This will activate A2, A3,B2,B3,C2,C3 Cells.

Sub Activating_multiple_Cells()

Range("A2:C3").Activate

End Sub

Example 3: Activating Multiple cells using VBA

We can also use the Cells syntax to active multiple Cells. The below macro will activate the same range (A2:C3) whcih we discussed above using Cells and Range object.

Sub Activating_multiple_Cells()

Range(Cells(2, 1), Cells(3, 3)).Activate

End Sub

Here Cells(2, 1) refers to A2 and Cells(3, 3) refers to C3. and wee need to use comma (,) instead of colon (:).

VBA for Activating 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
  2. Press Alt+F11 to Open VBA Editor
  3. Insert a Module from Insert Menu
  4. Copy the above code for activating a range and Paste in the code window(VBA Editor)
  5. Save the file as macro enabled workbook
  6. Press ‘F5’ to run it or Keep Pressing ‘F8’ to debug the code line by line.

Now, you can see the range A2:C3 is activated in the active worksheet.

Recent Posts:

  • VBA Error Statement

VBA Error Statement

Error handling plays a pivotal role in ensuring smooth and predictable code execution. While VBA provides mechanisms to handle errors, there are instances where simulating errors becomes necessary. Enter the 'Error' statement. In this blog [...]

  • VBA Date Function

VBA Date Function

The VBA Date function is a built-in function that is used to return the current system date. It can also be used to specify a specific date by providing the year, month, and day arguments. [...]

  • VBA Time Function

VBA Time Function

The VBA Time function is used to return the current system time. It is similar to the 'Now' function, but it only returns the time and not the date. This function can be very useful [...]

  • VBA String Function

VBA String Function

The VBA String function is a built-in function in Microsoft Excel that allows users to create a string, or a sequence of characters, of a specified length. This function is commonly used in VBA (Visual [...]

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

Leave A Comment