EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home VBA VBA Resources VBA Lookup & Reference Functions VBA Selecting Range
 

VBA Selecting Range

Ashwani Jaiswal
Article byAshwani Jaiswal
Madhuri Thakur
Reviewed byMadhuri Thakur

VBA Selecting Range

Excel VBA Selecting Range

To select any kind of range in VBA we have a function called SELECT. It doesn’t mean that what type of cells we want to select in the Excel worksheet. But, If we want to use the range of cells or a combination of cells in VBA, then VBA Select is the function that would help us in selecting the range of cells we want. In actual, SELECT is an application in VBA which is used by applying it after we choose the range of cells to be select. Choosing the cells we want to select doesn’t mean that we are actually selecting it. We need to place SELECT after we fix the cells which we want to consider in our range. The good thing about Select is, it does not have any syntax to be followed.

 

 

How to Select a Range of Cells in Excel VBA?

We will learn how to select a range of cells in Excel by using the VBA Code. For this, follow the below steps:

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

You can download this VBA Selecting Range Excel Template here – VBA Selecting Range Excel Template

Example #1

To apply the SELECT application using VBA,

Step 1: Insert a new module inside Visual Basic Editor (VBE). Click on Insert tab > select Module.

Insert Module

Step 2: Write the subprocedure of VBA Selecting Range in the same name or in the different names which defines the operation we do.

Code:

Sub VBA_Range()

End Sub

VBA Selecting Range Example 1-2

Step 3: Now suppose, if we want to select the range of cells from cell A1 to B10 then use RANGE and in inverted quotes put the cells under range.

Code:

Sub VBA_Range()

Range("A1:B10")

End Sub

Range function Example 1-3

Step 4: Now to select the required application, after a dot and select the application called SELECT as shown below.

Code:

Sub VBA_Range()

Range("A1:B10").Select

End Sub

VBA Selecting Range Example 1-3

Step 5: Now we will compile the code by pressing function key F8 and to run the code, click on the Play button located below the menu bar. We will see in the current worksheet, cells from A1 to B10 are selected or covered in the highlighted area.

Cells from A1 to B10 Example 1-4

Example #2

There is another way to select any random cell range we want. For this, we will use the same coding pattern that we saw in example-2. For this, follow the below steps:

Step 1: Write the subprocedure for VBA Selecting Range.

Code:

Sub VBA_Range2()

End Sub

VBA Selecting Range Example 2-1

Step 2: Now in the Range function, we will put the random cells that we want to select in place of sequential range. Let’s put cell A1, B2 and C3 separated by commas into the brackets.

Code:

Sub VBA_Range2()

Range("A1, B2, C3").Select

End Sub

Range function Example 2-2

Step 3: Now if the run the code, we will see cell A1, B2 and C3 will now be selected with a highlighted portion as shown below.

Cell A1, B2 and C3 Example 2-3

Example #3

There is one more method to select the Range. Here we will be using define a variable for RANGE function first. For this, follow the below steps:

Step 1: Write the subprocedure for VBA Selection Range. And in that define a variable for RANGE.

Code:

Sub VBA_Range3()

Dim SelectRNG As Range

End Sub

Define Variable Example 3-1

Step 2: Then use SET with defined variable and use RANGE function along with the cells which we want to select.

Code:

Sub VBA_Range3()

Dim SelectRNG As Range
Set SelectRNG = Range("A1:B10")

End Sub

RANGE function Example 3-2

Step 3: At last, use the SELECT application with a defined variable as shown below.

Code:

Sub VBA_Range3()

Dim SelectRNG As Range
Set SelectRNG = Range("A1:B10")
SelectRNG.Select

End Sub

VBA Selecting Range Example 3-3

Step 4: Now again compile the code if required and run. We will see the range of cells A1 to B10 will get selected with the highlighted region.

VBA Selecting Range Example 1-4

Example #4

There is also another simplest way to select the range. For this, follow the below steps:

Step 1: For this again open a module and write the subprocedure for VBA Selecting Range. Now we will be using the function call CELLS. CELLS function in VBA allows us to choose the cells we want to select.

Code:

Sub VBA_Range4()

End Sub

VBA Selecting Range Example 4-1

Step 2: Now put the cell numbers in the vertex of the X and Y positions. If we want to select the cell B3 then X would be 3 and Y would be 2 as shown below.

Code:

Sub VBA_Range4()

Cells(

End Sub

VBA Selecting Range Example 4-2

Step 3: Now use the SELECT application after the CELLS as shown below.

Code:

Sub VBA_Range4()

Cells(3, 2).Select

End Sub

VBA Selecting Range Example 4-3

Step 4: Now if we run the code, we will see, the cursor will be now placed to cell B3 as shown below.

VBA Selecting Range Example 4-4

Pros of VBA Selecting Range

  • Shown examples have different but easiest ways to select the range.
  • Selecting the range using directly RANGE function with SELECT is the best one-line code.
  • We can select cells as a range in continuously or randomly.

Things to Remember

  • To have a proper visual of range getting selected, put the cursor away from the range we want to select.
  • If we choose the randomly distributed cells as Range, then some operation becomes limited to it. Such as, we cannot copy or cut the data in such a pattern manually.
  • Processes shown for selecting the range in all the above examples are not limited to these. We can try the combination of all the different examples simultaneously we want.
  • Once coding is done, save the Excel file in Macro Enabled Excel format which would help in retaining and saving the code multiple times.

Recommended Articles

This is a guide to the VBA Selecting Range. Here we discuss how to Select a Range of Cells in Excel VBA along with practical examples and downloadable excel template. You can also go through our other suggested articles –

  1. VBA Input
  2. VBA Login
  3. VBA Month
  4. VBA Login

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Web Development & many more.

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA

Download VBA Selecting Range Excel Template

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW