LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Function to retrieve maximum value of Y axis scale in chart object


wrote in message
oups.com...
Hello All

Ok. So the problem is the following.

I have a simple line chart with 4 series. One of them is the actual
data series and the other 3 series represent the target areas
(formatted as stacked area type).

Now I have created dynamic ranges so that users may select a period and
the graph only displays the selected period. However I cant seem to get
the toped stacked layer (i.e. Bad performance area series) to match the
maximum value within the Y axis. (It's always sightly less).


Does it make sense to try a stacked 100% area on the secondary Y axis? Then
you will always match. Even if you make the value match exactly, Excel will
then increase the axis maximum, so your regular stacked area series won't
match it any more. Of course, the problem becomes having to choose
percentages for the area chart values (on the secondary axis) that will line
up with the primary axis.

I assume that you can't impose your own axis limits, because different
periods have values that are too different to use the same limits.

I have 2 ways to go about this:

i) Understand how excel calculates the maximum Y axis value and match
this value. (Currently I am using MAX function)


Microsoft published an article that explains how the axis limits are
selected, based on multiples of the major tick spacing. It never reveals how
this tick spacing is arrived at, so the article is of limited use.

ii) Retrieve the maximum value by creating a UDF in vba, however this
seems to be tricky as in vba I have to first activate the ChartObject
and then the Chart ... etc.


No, you don't have to activate anything. You can refer to an axis on a chart
on a different workbook's sheets without making it the active workbook. You
only (only!) need to know how to qualify the chart:

Workbooks("Book1.xls").Worksheets("Sheet 2").ChartObjects("Chart
3").Chart.Axes(xlCategory, xlPrimary)

iii) Define your own values for min and max, based on any algorithm you
want, and apply them to the chart. For a decent algorithm, check Stephen
Bullen's old post:

http://groups.google.com/group/micro...a8c7?hl=en&lr=

I've pinched this technique and applied it to worksheet formulas, rather
than a VBA UDF. For the ability to apply cell values to chart axis scales,
read this article:

http://peltiertech.com/Excel/Charts/...nkToSheet.html

This procedure to change the axis scale can be linked to a Worksheet_Change
or Worksheet_Calculate event, so it will behave like Excel's built in
dynamic axis scales. Except of course that you get to choose the limits.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to force chart axis to same scale Sandusky Excel Discussion (Misc queries) 3 February 18th 09 04:57 AM
How to draw chart: log scale on X axis, natural scale on y axis? Pratap D. chavan Charts and Charting in Excel 1 November 16th 06 08:03 AM
Function to retrieve maximum value of Y axis scale in chart object [email protected] Excel Programming 1 May 4th 06 06:07 PM
How to change maximum scale of a logarithmic chart on an EXCELL ch Mohammad Shahsavarifard Charts and Charting in Excel 1 August 22nd 05 01:51 PM
Cell value as chart scale maximum Phil Hageman Charts and Charting in Excel 9 December 17th 04 02:09 PM


All times are GMT +1. The time now is 11:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"