+ Reply to Thread
Results 1 to 3 of 3

Changing Chart Min & Max Axis Values via VBA

  1. #1
    Forum Contributor
    Join Date
    05-26-2004
    Location
    Halifax, UK
    MS-Off Ver
    Office 365 v2402
    Posts
    263

    Changing Chart Min & Max Axis Values via VBA

    I want to change the min and max y-axis values on a chart depending on the values in two cells on another worksheet. The code below is in the worksheet code module for the tab called "Dashboard(RR)" and first it checks to see if cell J3 has been changed (options from a drop-down menu) and if True then change the values on corresponding chart "RR_chart_2":

    Please Login or Register  to view this content.
    When I run this however I get the error "Runtime error '438' object doesn't support this property". I've used the macro recorder to change the axis min / max values manually and the code looks similar, but obviously I'm doing something wrong. I would guess it's a scope / object reference problem but can't figure out what's wrong. Anyone got any ideas???

    Thanks :-)

  2. #2
    Forum Contributor
    Join Date
    05-26-2004
    Location
    Halifax, UK
    MS-Off Ver
    Office 365 v2402
    Posts
    263

    Re: Changing Chart Min & Max Axis Values via VBA

    I thought this might fix it but I still get an error:

    Please Login or Register  to view this content.
    This time I get "The specified dimension is not valid for the current chart type", although I know the values in ranges L27 and L28 I'm referring to are definitely valid numbers and I can manually change the chart min and max settings to those exact numbers!

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,442

    Re: Changing Chart Min & Max Axis Values via VBA

    I don't access charts very often with VBA, but I think the error is about specifying the chart object -- not really about changing the axis scale. I think what happens is that there is both a Chart object and a ChartObject object, and you need to specify both when referencing an embedded. From other examples I see around the net, this change to post #1 should work (or at least do something different:
    Please Login or Register  to view this content.
    Notice that there is both a ChartObjects object and a separate Chart object within the ChartObject object (don't ask me why).

    If it helps, Jon Peltier has a nice tutorial here for linking axis parameters to cells: https://peltiertech.com/link-excel-c...lues-in-cells/ If you are really excited by this, you might follow the link at the end of that essay to the one about using a UDF for the task.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ 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. [SOLVED] create x-axis and a y-axis chart as an image horizontal and vertical values
    By Khaldon in forum Excel Charting & Pivots
    Replies: 9
    Last Post: 10-11-2018, 09:12 AM
  2. Replies: 1
    Last Post: 06-21-2016, 12:26 AM
  3. Changing chart type & second axis on chart with 2-level axis labels
    By trolle in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 04-15-2016, 09:52 AM
  4. Replies: 9
    Last Post: 09-22-2015, 02:43 AM
  5. Scatter chart x axis labels not changing to appropriate values
    By Vbot in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 10-14-2014, 10:54 PM
  6. Replies: 8
    Last Post: 02-12-2009, 10:12 AM
  7. Changing the x-axis values on a logarithmic chart?
    By c991257 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 10-30-2008, 07:18 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