PC Review


Reply
Thread Tools Rate Thread

Auto adjust Y-axis for chart with 2

 
 
jaydywan@gmail.com
Guest
Posts: n/a
 
      8th Aug 2007
Someone posted the following, to automatically adjust the Y-axis of an
excel chart depending on the data range. This works for charts with
one axis, but does someone know the code to apply this when a chart
has 2?
------
Hi All Excel-VBA Experts,

I want to write a macro which would automatically adjust the Y-axis of
an excel chart depending on the data range..

Basically I have a chart pointing to a data range. The data range
often changes but the chart doesn't rescale itself to adjust for the
maximum resolution .. The excel auto option doesn't seem to be that
effective..

One way i could think of was to scan for the min & max values in the
data range but dont know how to adjust the chart axes then...

Any help would be greatly appreciated.
Thanks.
-Sunil

----

Hi

see in the PDF file (sample chapter) of chapter 15 of

Professional Excel Development

Written by Stephen Bullen, Rob Bovey and John Green

http://www.oaltd.co.uk/ProExcelDev/Default.htm

It's on one of the last pages, if I recall well. Nice stuff, I use it
too in
one of my private Excel files.

--
Wigi

 
Reply With Quote
 
 
 
 
Toyin.Butler@googlemail.com
Guest
Posts: n/a
 
      8th Aug 2007
To set the Maximum scale, find the highest value in your series - e.g
dblIntMax in my code below. Then use a function like the one below to
ascertain the scale.

ActiveSheet.ChartObjects("Chart 1").MaximumScale =
IntRoundUp(dblIntMax)

Function IntRoundUp(zRate)
Dim zDecimal As Single, zRound As Single

zDecimal = zRate - Int(zRate)

Select Case zDecimal
Case Is < 0.25
zRound = 0.25
Case Is < 0.5
zRound = 0.5
Case Is < 0.75
zRound = 0.75
Case Is < 1
zRound = 1
End Select

IntRoundUp = Int(zRate) + zRound

End Function

It depends on the increments you are looking for, this example deals
with interest rates and so the rounding is done on 0.25 basis.

hth

Toyin.

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      9th Aug 2007
It's the same answer, except you need to determine the min and max on each
axis,compute two sets of scales, and apply them to the two axes.

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


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Someone posted the following, to automatically adjust the Y-axis of an
> excel chart depending on the data range. This works for charts with
> one axis, but does someone know the code to apply this when a chart
> has 2?
> ------
> Hi All Excel-VBA Experts,
>
> I want to write a macro which would automatically adjust the Y-axis of
> an excel chart depending on the data range..
>
> Basically I have a chart pointing to a data range. The data range
> often changes but the chart doesn't rescale itself to adjust for the
> maximum resolution .. The excel auto option doesn't seem to be that
> effective..
>
> One way i could think of was to scan for the min & max values in the
> data range but dont know how to adjust the chart axes then...
>
> Any help would be greatly appreciated.
> Thanks.
> -Sunil
>
> ----
>
> Hi
>
> see in the PDF file (sample chapter) of chapter 15 of
>
> Professional Excel Development
>
> Written by Stephen Bullen, Rob Bovey and John Green
>
> http://www.oaltd.co.uk/ProExcelDev/Default.htm
>
> It's on one of the last pages, if I recall well. Nice stuff, I use it
> too in
> one of my private Excel files.
>
> --
> Wigi
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
adjust axis range and major units in xy-chart to data series values biker Microsoft Access Forms 0 3rd Sep 2009 01:25 AM
How to adjust chart auto'ly as new data is entered? curiousgeorge408@hotmail.com Microsoft Excel Misc 2 31st Jul 2008 05:37 PM
Auto adjust dates in a chart Paul Microsoft Excel Charting 1 30th Jul 2008 06:01 PM
Auto expanding x axis of a chart. xanderr84@gmail.com Microsoft Excel Programming 0 25th Jun 2007 02:08 PM
adjust data axis of the chart Taha Microsoft Excel Charting 2 15th Nov 2003 12:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:56 PM.