Select Cells in Excel using Macros and VBA

Add to Favorites
Author:

This is actually a very easy thing to do and only requires a couple lines of code. Below I will show you how to select a cell or a range of cells on the currently active or visible worksheet in Excel.

The simplest way to this is with a macro like this:

Sub Select_Cells_in_Excel()

'Select a single cell in the current worksheet
Range("C4").Select

'Or
Cells(4, 3).Select

End Sub

Copy and paste this into your Excel workbook and read the comments, which will appear in green, to follow everything.

The basic way to select a cell in the currently active worksheet in Excel is to use this method:

Range(A1).Select

This is pretty simple to understand.  All you have to do is to change A1 to whichever cell you want to be selected.  Thats it!

I prefer to use the range method since it is the simplest way to select a cell.  When you create more advanced macros in VBA you may need to use the Cells method.

Cells(4,3).Select

This sample is in the macro above and it points you to cell C4.  The first number is the row of the cell to select, 4, and the second number is the column, 3.  To get the column number you just count from 1, which is the letter A down to the letter column you wish to reference.  A =1, B=2,C=3, etc.

So, you can see that it is actually very easy to select a cell in Excel using macros and VBA.  If I were you, I would stick to using the Range method of doing this just because it is so much easier to tell which cell is being referenced just by looking at the code in question.


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 Ranges of Cells in Excel using Macros and VBA
Tutorial: This Excel VBA tutorial focuses specifically on selecting ranges of cells in Excel.  This...
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 ...
VBA File Selection Window to Open Files in Excel
Tutorial: Make a file selection browser in Excel using VBA/Macros - this is the file window that al...
Automatically Lock Certain Cells in Excel using a Macro
Tutorial: This macro allows you to have a cell automatically locked after a user enters something in...
Center Titles Across Multiple Cells in Excel
Tutorial: How to center a title across multiple cells in Excel in order to make good looking titles...
Print Selected Worksheets in Excel
Macro: This free excel macro will print all selected worksheets in Excel. If there are no ot...
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