PDA

View Full Version : Cell references within VBA in an Excel macro


rmccafferty
Jul 27, 2008, 04:34 PM
In a macro in Excel I want to refer to a cell where the user entered a number. I want that number to be the row number for the macro to move to. (I will then select the entire row and copy it to row 1, which I know how to do).

How can I tell the macro which row to go to, using the number that has, in this case, been entered into cell A3? That is, if the user entered the number 11 in cell A3, how to I tell the macro to to to A11?

I assume I need to use a variable. If so, I know how to declare the variable, but not the syntax for assigning a value to the variable in Excel or now to use that variable within a reference to a cell location.

Thanks,
Robert
[email protected]

JBeaucaire
Jul 27, 2008, 11:46 PM
In the VBA code, the following line would do what you want:

Range("A3").Select