Select Ranges of Cells in Excel using Macros and VBA

Add to Favorites
Author:

This Excel VBA tutorial focuses specifically on selecting ranges of cells in Excel.  This means that you will learn how to select multiple contiguous cells in the same row, column, or worksheet.  There are many ways to do this but, below, I will show you the simplest way to select ranges with VBA.

Sub Select_Cells_in_Excel()

'Select a range of cells in the current worksheet
Range("A1:B5").Select

'Or
Range("A1", "B5").Select

End Sub

Put the above macro in your workbook and you will more clearly be able to see the comments and the two lines of actual code.

As you can see, it is really easy to select a range and, logically enough, you use the Range method to do so.

To select a range just start with Range and then input the desired range of cells to select or work on.  If you want to select the range A1:A5, input Range(A1:A5).Select and thats it.  Remember that this will select the range on the currently active or visible worksheet in Excel.

All you have to do to select a different range is to change A1 and A5 to whatever you want.  Note, to select a range, the first cell reference that you input should be for the cell in the upper left part of the range; the second cell reference that you input should be for the bottom right part of the range that you want to select.

If you wanted to select all the cells in columns A, B, & C and all the rows from 1 to 10, you would use this piece of code: Range(A1:C10).Select

You will also notice that there is a second way to reference a range using Range in Excel and there are actually a few other, but much more complicated, ways to do so.  The second method above is used much like the first.  The upper left cell reference for the range is the first reference and the lower right cell reference for the range is the second number.  But, unless you need to do more complex things in Excel, I would stick to using the first method, it is much easier to understand and read later when you go over your VBA code.


Question? Ask it in our Excel Forum


Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons 50+ Hours of Instruction 200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Similar Content on TeachExcel
Select Cells in Excel using Macros and VBA
Tutorial: This is actually a very easy thing to do and only requires a couple lines of code. Below I...
Loop through a Range of Cells in Excel VBA/Macros
Tutorial: How to use VBA/Macros to iterate through each cell in a range, either a row, a column, or ...
Count The Number of Words in a Cell or Range of Cells in Excel - UDF
Macro: Count words in cells with this user defined function (UDF). This UDF allows you to count t...
Limit the Total Amount a User Can Enter into a Range of Cells in Excel
Tutorial: How to limit the amount that a user can enter into a range of cells in Excel.  This works...
Count The Number of Words in a Cell or Range of Cells in Excel - With User-Specified Delimiter / Separator - UDF
Macro: UDF to count the number of words in a cell or range with a user-specified delimiter. ...
Make Rounded Corner Cells in Excel
Tutorial: Forms Course How to round the corners of cells in Excel so they look so much better. This...
Tutorial Details
Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course