?
Solved

Error when using variable to activate a worksheet

Posted on 2011-10-04
3
Medium Priority
?
187 Views
Last Modified: 2012-05-12
I am trying to pass a variable to activate an excel worksheet. My code is:

    Worksheets(strWKS).Activate

with strWKS as a string being passed to the function.
Application defined or object defined error.

Am I missing something?
0
Comment
Question by:smm6809
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
andrewssd3 earned 2000 total points
ID: 36910839
The workbook containing your sheet must be activated first for this to work - is that the issue?
0
 

Author Comment

by:smm6809
ID: 36910858
I am running code from a command button right in the worksheet
0
 

Author Closing Comment

by:smm6809
ID: 36910903
You were right.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question