Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ant
 
Posts: n/a
Default Changing the scale major unit in a graph

I have a graph which is linked to a range which changes (through data
validation and SUMIF's). There are several Countries which have varying data
totals which the graph picks up. ie for Country 1 the scale maximum is 100
and for Country 2 the scale maximum is 20. What does not automatically change
however is the scale major unit. If this is manually changed to 20 for
Country 1 it remains that way for Country 2 which is of no use as with a
scale maximum of 20, I need the scale major unit to be say, 2. I am looking
for a way to change the scale major unit automatically. I would like to use
similar code below attached to a data validation cell;

ActiveChart.Axes(xlValue).MajorUnit = 20

Is it somehow possible to link the number 20 above to a cell? That way I can
have a simple formula which can be linked to the range total eg 100 and
divide it by 5. This would give me 20 for Country 1 and 2 for Country 2.
  #2   Report Post  
Posted to microsoft.public.excel.misc
Andy Pope
 
Posts: n/a
Default Changing the scale major unit in a graph

Hi,

You can not directly link the scales properties to a cell.
What you could do with VBA is to add code to a worksheet event that
updates the scale property.

For example this assumes the scale value is in E1. E1 contains a formula
that outputs 20 or 100 dependent on some test related to country selection.

Private Sub Worksheet_Calculate()

ActiveSheet.ChartObjects(1).Chart.Axes(xlValue).Ma jorUnit = _
Range("E1").Value

End Sub

Cheers
Andy

Ant wrote:
I have a graph which is linked to a range which changes (through data
validation and SUMIF's). There are several Countries which have varying data
totals which the graph picks up. ie for Country 1 the scale maximum is 100
and for Country 2 the scale maximum is 20. What does not automatically change
however is the scale major unit. If this is manually changed to 20 for
Country 1 it remains that way for Country 2 which is of no use as with a
scale maximum of 20, I need the scale major unit to be say, 2. I am looking
for a way to change the scale major unit automatically. I would like to use
similar code below attached to a data validation cell;

ActiveChart.Axes(xlValue).MajorUnit = 20

Is it somehow possible to link the number 20 above to a cell? That way I can
have a simple formula which can be linked to the range total eg 100 and
divide it by 5. This would give me 20 for Country 1 and 2 for Country 2.


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #3   Report Post  
Posted to microsoft.public.excel.misc
Ant
 
Posts: n/a
Default Changing the scale major unit in a graph

That works perfectly - thanks Andy.

"Andy Pope" wrote:

Hi,

You can not directly link the scales properties to a cell.
What you could do with VBA is to add code to a worksheet event that
updates the scale property.

For example this assumes the scale value is in E1. E1 contains a formula
that outputs 20 or 100 dependent on some test related to country selection.

Private Sub Worksheet_Calculate()

ActiveSheet.ChartObjects(1).Chart.Axes(xlValue).Ma jorUnit = _
Range("E1").Value

End Sub

Cheers
Andy

Ant wrote:
I have a graph which is linked to a range which changes (through data
validation and SUMIF's). There are several Countries which have varying data
totals which the graph picks up. ie for Country 1 the scale maximum is 100
and for Country 2 the scale maximum is 20. What does not automatically change
however is the scale major unit. If this is manually changed to 20 for
Country 1 it remains that way for Country 2 which is of no use as with a
scale maximum of 20, I need the scale major unit to be say, 2. I am looking
for a way to change the scale major unit automatically. I would like to use
similar code below attached to a data validation cell;

ActiveChart.Axes(xlValue).MajorUnit = 20

Is it somehow possible to link the number 20 above to a cell? That way I can
have a simple formula which can be linked to the range total eg 100 and
divide it by 5. This would give me 20 for Country 1 and 2 for Country 2.


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

Reply
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
Automatically changing the range in a graph Bret Davis Charts and Charting in Excel 1 January 14th 06 08:13 PM
changing the color of a single bar on a graph Brian Charts and Charting in Excel 1 November 22nd 05 05:55 PM
Graph on Inverted Scale Deepak Thakkar Charts and Charting in Excel 2 July 26th 05 08:04 AM
Changing Graph Title W/ Pivot Jenn Excel Discussion (Misc queries) 1 January 19th 05 04:42 AM
Bar graph values keep changing Mike82j2000 Charts and Charting in Excel 1 January 6th 05 02:27 PM


All times are GMT +1. The time now is 12:04 AM.

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

About Us

"It's about Microsoft Excel"