Select Cells in Excel using Macros and VBA

Add to Favorites
Author: don

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



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 ...
Loop through All Worksheets in Excel using VBA and Macros
Tutorial: Ill show you how to loop through all of the worksheets in a workbook in Excel using VBA an...
Print Preview Screen Display for The Current or Selected Worksheets in Excel
Macro: This free Excel macro allows you to display the print preview screen or window for the cur...
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...
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...