positioning in a specific cell using a macro

  • Thread starter Thread starter chrprog
  • Start date Start date
C

chrprog

I have a value "a11" in q4, and want to go to sheet2 and positioning in the
a11 cell using a macro.
 
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
 
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top