Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Skip if variable not determined

I have the following function that I use to adjust the scale on my y-axis.
My sheet has around 12 charts that are updated, but sometimes they might not
contain data causing the macro to holt on the GetChartMin Function.

How can I Skip the yAxis loop when GetChartMin cannot be determined.

Regards,

Bruce

Private Function yAxis()
arrChart = Array("Summary")
For Each a In arrChart
For Each Chart In Sheets(a).ChartObjects()
Chart.Activate
High = GetChartMax(ActiveChart, 1) * 1.01
low = GetChartMin(ActiveChart, 1) * 0.995
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = low
.MaximumScale = High
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlCustom
.CrossesAt = 0
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Next Chart
Next a
Range("A1").Select
End Function

Private Function GetChartMax(MyChart As Chart, SeriesIndex As Integer) As
Double
GetChartMax =
Application.WorksheetFunction.Max(MyChart.SeriesCo llection(SeriesIndex).Values)
End Function

Private Function GetChartMin(MyChart As Chart, SeriesIndex As Integer) As
Double
GetChartMin =
Application.WorksheetFunction.Min(MyChart.SeriesCo llection(SeriesIndex).Values)
End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Skip if variable not determined

If I read you right then your statement 'but sometimes they might not
contain data' is the clue. If your data resides in worksheet cells, then I
suggest you test the contents of the data range to see if there is data or
not. You do not state what constitutes missing data if you could be more
explicit then I am sure a solution is possible. For example you could sum
the range and if it is zero, or if the max = min etc.... sometimes these
of course might be valid.

--
Cheers
Nigel



"Bruce" wrote in message
...
I have the following function that I use to adjust the scale on my y-axis.
My sheet has around 12 charts that are updated, but sometimes they might
not
contain data causing the macro to holt on the GetChartMin Function.

How can I Skip the yAxis loop when GetChartMin cannot be determined.

Regards,

Bruce

Private Function yAxis()
arrChart = Array("Summary")
For Each a In arrChart
For Each Chart In Sheets(a).ChartObjects()
Chart.Activate
High = GetChartMax(ActiveChart, 1) * 1.01
low = GetChartMin(ActiveChart, 1) * 0.995
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = low
.MaximumScale = High
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlCustom
.CrossesAt = 0
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Next Chart
Next a
Range("A1").Select
End Function

Private Function GetChartMax(MyChart As Chart, SeriesIndex As Integer) As
Double
GetChartMax =
Application.WorksheetFunction.Max(MyChart.SeriesCo llection(SeriesIndex).Values)
End Function

Private Function GetChartMin(MyChart As Chart, SeriesIndex As Integer) As
Double
GetChartMin =
Application.WorksheetFunction.Min(MyChart.SeriesCo llection(SeriesIndex).Values)
End Function



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
SUM determined by drop-down list RICH1B Excel Worksheet Functions 9 April 19th 10 10:13 PM
how are random numbers determined hectorvector Excel Worksheet Functions 2 June 10th 05 01:55 PM
tabbing in a pre-determined direction PatS Excel Discussion (Misc queries) 3 January 17th 05 02:09 AM
how do i use the function to copy and paste a determined variable. Strem Excel Worksheet Functions 2 January 8th 05 05:31 PM
Determined to eliminate .select Bruce Roberson Excel Programming 10 August 14th 03 12:34 PM


All times are GMT +1. The time now is 09:24 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"