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.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
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?
 
Upvote 0
Actually both the posted codes will do that.

What do you actually want to do?
 
Upvote 0
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?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,044
Members
449,063
Latest member
ak94

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top