+ Reply to Thread
Results 1 to 7 of 7

VBA to Link Chart Options to Cells

  1. #1
    Forum Contributor
    Join Date
    06-10-2005
    MS-Off Ver
    2007
    Posts
    223

    VBA to Link Chart Options to Cells

    Hi,
    I have a line chart with 2 items and I want to have the minimum and maximum y-axis link to specific cells, as well as the major units for the x-axis. I found some code to do this and I added this into the VBA screen, but it doesn't work for some reason. Note that I put a single quote in front of the code that I don't need right now, but may need in the future.
    Any suggestions would be appreciated.

    Thanks,
    Phillycheese
    Attached Files Attached Files
    Last edited by Phillycheese5; 02-23-2016 at 12:36 PM.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: VBA to Link Chart Options to Cells

    This forum can be pretty strict about putting code in code tags. You should do this to avoid getting your topic locked.

    I think the problem is the location of your code, not the code itself. Fix the code tag issue, and we can discuss further, if needed.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Contributor
    Join Date
    06-10-2005
    MS-Off Ver
    2007
    Posts
    223

    Re: VBA to Link Chart Options to Cells

    Hey MrShorty, sorry about that---I haven't posted in the VBA section before (just the formula/function). The only reason I put the code in because it didn't seem too long and figured it would be easier for someone to view instead of having to download and check out the file. I don't know what a code tag is, but I will edit my original post to remove the code. Again, apologies.
    Last edited by Phillycheese5; 02-22-2016 at 01:15 PM.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: VBA to Link Chart Options to Cells

    Putting code into your posts will be a useful skill. Follow the "Forum Rules" link above and read #3, which describes how to use code tags.

    Like I said, in this case, the problem isn't the code itself, but that you appear to have placed the code in a normal module. Event code needs to be placed in the module associated with the object it applies to. In this case, it seems to work just fine if you move the code from "Module1" to the "Sheet1" module.

  5. #5
    Forum Contributor
    Join Date
    06-10-2005
    MS-Off Ver
    2007
    Posts
    223

    Re: VBA to Link Chart Options to Cells

    Hi MrShorty, thanks for the direction!! I moved it as you suggested and it works as expected! I will check out the code tags as well.

    Thanks again!!
    Phillycheese

  6. #6
    Forum Contributor
    Join Date
    06-10-2005
    MS-Off Ver
    2007
    Posts
    223

    Re: VBA to Link Chart Options to Cells

    Hi,
    I have added an second chart to my original file (only 1 chart is in the uploaded file) and copied the code so I can apply it to the second chart in the same worksheet. But I got the following compile error "Ambiguous name detected: Worksheet_Change". I tried to resolve it without success.

    I plan to have 4 charts in the same worksheet, each whose options I would like to link to different cells, so any help would be appreciated.

    Thanks,
    Phillycheese

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: VBA to Link Chart Options to Cells

    I have added an second chart to my original file (only 1 chart is in the uploaded file) and copied the code so I can apply it to the second chart in the same worksheet. But I got the following compile error "Ambiguous name detected: Worksheet_Change".
    I cannot be sure exactly what you have done. If I read this correctly, did you end up with two "worksheet_change" event procedures for the same worksheet? When you make a change in the spreadsheet, how should Excel/VBA know which change procedure to execute?

    If this is correct, the solution is to structure the code so that there is only one "worksheet_change" procedure that is able to determine -- which cell was changed, which chart (or charts) that change should apply to, and then perform the change. You cannot have 4 identical change procedures.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Chart Filter Options
    By mAro817 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 12-08-2015, 01:38 PM
  2. Replies: 1
    Last Post: 12-15-2012, 11:32 AM
  3. How to link Droplist options with Graphs
    By PuckBunny in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-27-2009, 06:13 AM
  4. Excel 2007 edit link options
    By H&MITGuy in forum Excel General
    Replies: 0
    Last Post: 03-12-2009, 02:51 PM
  5. Chart Options
    By TwoyTaylor in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-26-2008, 08:44 PM
  6. [SOLVED] How do I link Excel chart axis scale settings to cells?
    By strince in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-11-2005, 05:05 PM
  7. Link Chart Axis Scale Parameters to Values in Cells via Macro or Button
    By Ronald de Vries in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-22-2005, 08:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1