+ Reply to Thread
Results 1 to 6 of 6

Automatically set min & max scale for y-axis

  1. #1
    Registered User
    Join Date
    08-20-2008
    Location
    Finland
    Posts
    13

    Automatically set min & max scale for y-axis

    Hi,

    I am writing a code, which would automatically set min and max scale for y-axis.

    I have a chart, which adds new given values automatically (this is carried out using OFFSET and COUNTA-functions: the named ranges expand when adding new values, and the chart uses these dynamical areas.)

    However, min and max scale of the y-axis don't change automatically (as I would like them to change.)

    I'm quite a beginner with visual basic, but I finally managed to come out with this:

    (This code is located in Modules: Module 3 - is this the right place?)

    Please Login or Register  to view this content.
    The code above is called by the next code (for example):

    (The next code is located in Microsoft excel objects: Thisworkbook - Is this the right place?)

    Please Login or Register  to view this content.
    The previous example updates the scaling of the chart called "nameofthechart", and the difference between the maximum value (minimum value) and the y-maximum (y-minimum) scale is 10 percent.

    Is this a practical way to carry this out? Would you prefer some other way to do this?

    The code seems to work properly when there is just one data series in the chart. But when there is for example two data series (xy scatter), it gives an error message when adding values just to the other series (so that the series contain different number of records)

    Debugger highlights the row

    Please Login or Register  to view this content.
    How could this be prevented?

    Thank you!
    Last edited by tms_; 08-20-2008 at 08:32 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441
    I can not duplicate your problem.

    Are all the values for each series valid? no empty cells or #N/A's

    Can you post example workbook?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    08-20-2008
    Location
    Finland
    Posts
    13

    solution found

    Thank you Andy!

    I found out what was causing the problem. I had defined the names incorrectly... (there wasn't an equal number of rows in every column in these cases that caused the problems)

    By the way, how does the code seem like? Do you think it is proper, logical etc.?
    Last edited by tms_; 08-22-2008 at 05:25 AM.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441
    code looks fine.
    Does it do what you want?

  5. #5
    Registered User
    Join Date
    08-20-2008
    Location
    Finland
    Posts
    13
    Yes, it seems to work.

    I would also like to give the user a chance to let the excel adjust the max & min values automatically.

    Would you know, how this could be carried out?

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441
    You could add code to check the Min and or MAX arguments in your function.
    Allow the user to specify TRUE for automatic. Add code to the function to check whether the parameters contain valid numeric values.
    If not check for content being TRUE and then set the scale properties to automatic.

+ 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. Automatically adjusting X axis date range
    By RubberToe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-19-2008, 02:53 PM
  2. Automatically adjusting x-axis scale
    By braydon16 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 05-02-2008, 12:24 AM
  3. chart scale from actual Y axis data
    By robert111 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-12-2008, 09:41 AM
  4. y axis scale dynamically
    By zepoltwins in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-22-2008, 06:47 PM
  5. Going insane!
    By kik in forum Excel - New Users/Basics
    Replies: 10
    Last Post: 01-31-2007, 08:21 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