positioning in a specific cell using a macro

C

chrprog

I have a value "a11" in q4, and want to go to sheet2 and positioning in the
a11 cell using a macro.
 
M

Mike H

Hi,

Sheets("Sheet2").Range("A11").select

This can't be done with worksheet code, unless that code is in Sheet 2, and
also note it's highly unlikely you need to select the cell to do what you
want.

Mike
 
R

Rick Rothstein

Try this code....

Worksheets("Sheet2").Activate
Range(Worksheets("Sheet1").Range("Q4").Value).Activate

Notice that you will need to specify the worksheet's name that Q4 is on in
the second statement (I used an example name of Sheet1); that is because the
first statement activates the sheet you want to be on, so you can't rely on
the active sheet to get the value in Q4.
 
R

Rick Rothstein

IF the cell Q4 that you will get the cell address on Sheet2 from could be on
any one of several different sheets, then you can use this code to do what
you want...

SheetName = ActiveSheet.Name
Worksheets("Sheet2").Activate
Range(Worksheets(SheetName).Range("Q4").Value).Activate
 
Top