How to select a cell in a non-active sheet

MR Campbell

Board Regular
Joined
Aug 2, 2002
Messages
113
I have a routine where i wish to select a cell in a non-active sheet - when I mean select, I simply mean to place the "cursor" at this cell.


E.g. If SheetA is the active sheet and I want to place the cursor in cell "B2" on SheetB, the code below does not work :

Sheets("SheetB").Range("B2").Select

At the moment it generates an error message.
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,086
Office Version
  1. 365
Platform
  1. Windows
Try something like this.
Code:
Sheets("SheetB").Activate
Range("B2").Activate
By the way why do you want to do this?

Is it just to set the focus on that cell once your code is finished?
 

MR Campbell

Board Regular
Joined
Aug 2, 2002
Messages
113

ADVERTISEMENT

Is this a solution ?

Will this cause the code to jump to SheetB ... I dont wish this to happen.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,086
Office Version
  1. 365
Platform
  1. Windows
Actually both the posted codes will do that.

What do you actually want to do?
 

just_jon

Legend
Joined
Sep 3, 2002
Messages
10,473
Not like that, but you could use a sheet selection event so that whenever SheetB was activated the cursor would be in B2

But what is your goal in doing this?
 

tusharm

MrExcel MVP
Joined
May 28, 2002
Messages
11,028
Re: Is this a solution ?

As others have implied but not explicitly stated one cannot select a cell in a non-active sheet. Think about it this way. Imagine you want to highlight a phrase on a particular page in a book. How would you do it without turning to that page?

MR Campbell said:
Will this cause the code to jump to SheetB ... I dont wish this to happen.
 

Watch MrExcel Video

Forum statistics

Threads
1,119,136
Messages
5,576,295
Members
412,716
Latest member
Ardin
Top