Set Variable Equal to Specific Sheet

  • Thread starter Thread starter Larry R Harrison Jr
  • Start date Start date
L

Larry R Harrison Jr

I have Excel 2003. I am trying to activate a given worksheet (which is
already open as a "window"); its name is in a string variable named stX.

To activate it, I tried this:

Dim stSt as Worksheet
set stSt=Worksheet(stX)
Windows(stSt).Activate

But I get "subscript out of range."

I know I'm close just can't quite get it. And searches in Google aren't
finding me anything; I know there MUST be something in there.

Tips?

LRH
 
Larry R Harrison Jr said:
I have Excel 2003. I am trying to activate a given worksheet (which is
already open as a "window"); its name is in a string variable named stX.

To activate it, I tried this:

Dim stSt as Worksheet
set stSt=Worksheet(stX)
Windows(stSt).Activate

But I get "subscript out of range."

I know I'm close just can't quite get it. And searches in Google aren't
finding me anything; I know there MUST be something in there.

Tips?

LRH

Larry,

try Worksheets(stX)

cheers,
Stephan
 
In addition to the previous post: stSt is already an object variable, the
last line should read: stst.activate

Stephan
 

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