Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

ActiveSheet.Name not working when used with ActiveChart.Location?Helpful Member! 

KiwiSteve (Programmer) (OP)
5 Feb 05 9:51
I have a macro which constructs a chart - it works fine with hard-coded sheet names, but I need it to work on other sheets.  When I substitute the sheet name with ActiveSheet.Name it no longer works...

eg. This works:

   ActiveChart.Location Where:=xlLocationAsObject, _
      Name:= "JAN05 (01FEB05 @ 1524)"

This doesn't:

   ActiveChart.Location Where:=xlLocationAsObject, _

Any help would be greatly appreciated.  I've been stuck on this now for 2 days!

Helpful Member!  SkipVought (Programmer)
5 Feb 05 16:26


Problem is, the active THING is NOT a sheet; rather its a CHART.

if you go to the VB Editor and STEP thru the code, you'll see that your new chart is originally a Chart Sheet and NOT an embedded chart in a worksheet.  


Be advised: The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?"

KiwiSteve (Programmer) (OP)
6 Feb 05 4:50
Thanks for the tip!

Setting up the sheet name outside the "charting block"...

    Dim SheetName As String
    SheetName = ActiveSheet.Name

...followed by...

    ActiveChart.Location _
        Where:=xlLocationAsObject, _

Did the trick nicely.
SkipVought (Programmer)
7 Feb 05 9:13

I would get in the habit of NOT relying on SELECT and ACTIVATE, referring to ActiveWhatever.  Rather refer to SPECIFIC objects.  Selecting and Activating slows down your program and can be confusing.

How Can I Make My Code Run Faster?   FAQ707-4105


Be advised: The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?"

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close