ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set Focus on Cell D8 (https://www.excelbanter.com/excel-programming/339736-set-focus-cell-d8.html)

Sandy

Set Focus on Cell D8
 
Hello -

I have the following code that doesn't work:

Sheet2.Activate
Range("D8").Select
Range("D8").Activate

What am I doing wrong?

The user clicks a button, it goes through code and at the end, they get
switched to Sheet2. It does go to Sheet2, but the selected cell is dependent
on where I left it the last time, not on the code above, for some reason.
--
Sandy

Gary''s Student

Set Focus on Cell D8
 
Your code works. Open a new, blank, workbook and paste in:

Sub m()
Sheet2.Activate
Range("D8").Select
Range("D8").Activate
End Sub

It always takes you to D8 in Sheet2.

Something outside you posted code is re-selecting a different cell.
--
Gary''s Student


"Sandy" wrote:

Hello -

I have the following code that doesn't work:

Sheet2.Activate
Range("D8").Select
Range("D8").Activate

What am I doing wrong?

The user clicks a button, it goes through code and at the end, they get
switched to Sheet2. It does go to Sheet2, but the selected cell is dependent
on where I left it the last time, not on the code above, for some reason.
--
Sandy


Gary Keramidas[_2_]

Set Focus on Cell D8
 
try this and see if it works

Sheets("Sheet2").Range("D8").Select

--


Gary


"Sandy" wrote in message
...
Hello -

I have the following code that doesn't work:

Sheet2.Activate
Range("D8").Select
Range("D8").Activate

What am I doing wrong?

The user clicks a button, it goes through code and at the end, they get
switched to Sheet2. It does go to Sheet2, but the selected cell is
dependent
on where I left it the last time, not on the code above, for some reason.
--
Sandy




Juan Pablo González

Set Focus on Cell D8
 
Another option (and usually more reliable from my experience)

Application.GoTo Sheets("Sheet2").Range("D8"), True

--
Regards,

Juan Pablo González
Excel MVP

"Sandy" wrote in message
...
Hello -

I have the following code that doesn't work:

Sheet2.Activate
Range("D8").Select
Range("D8").Activate

What am I doing wrong?

The user clicks a button, it goes through code and at the end, they get
switched to Sheet2. It does go to Sheet2, but the selected cell is
dependent
on where I left it the last time, not on the code above, for some reason.
--
Sandy




Sandy

Set Focus on Cell D8
 
Hi All!

Thank you very much!!

I ended up using Juan's -- seems like my app needed more of a description of
where it should go . . . or something . . . at any rate, it's working now.
--
Sandy


"Sandy" wrote:

Hello -

I have the following code that doesn't work:

Sheet2.Activate
Range("D8").Select
Range("D8").Activate

What am I doing wrong?

The user clicks a button, it goes through code and at the end, they get
switched to Sheet2. It does go to Sheet2, but the selected cell is dependent
on where I left it the last time, not on the code above, for some reason.
--
Sandy



All times are GMT +1. The time now is 12:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com