LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 177
Default Auto Scale Chart Macro -- Any improvements please?

This is the best way I've found to correctly scale a chart -- the only way I
found to exclude a chart interpolating with #NA cells was to delete those
cells containing #NA, and run the chart. This takes a long time on my
computer. Wondering if there is a better way. This macro is directly taken
from 2 excel mvps and modified; i believe a mehta and ron bovarty, but could
be wrong. Thanks for taking a look.

Sub AutoScaleYAxes()
Dim ValuesArray(), SeriesValues As Variant
Dim Ctr As Integer, TotCtr As Integer

Application.Run "Extend_Stock_Data"
Application.Run "Delete_Row_NA_Data"

Sheets("SnapShot").Select
ActiveSheet.ChartObjects("CIQChart1s0t0").Activate
ActiveChart.PlotArea.Select
ActiveWindow.Visible = False

With ActiveChart
On Error Resume Next
For Each X In .SeriesCollection
SeriesValues = X.Values
ReDim Preserve ValuesArray(1 To TotCtr + UBound(SeriesValues))
For Ctr = 1 To UBound(SeriesValues)
ValuesArray(Ctr + TotCtr) = SeriesValues(Ctr)
Next
TotCtr = TotCtr + UBound(SeriesValues)
Next
.Axes(xlValue).MinimumScaleIsAuto = True
.Axes(xlValue).MaximumScaleIsAuto = True
.Axes(xlValue).MinimumScale = Application.Min(ValuesArray)
.Axes(xlValue).MaximumScale = Application.Max(ValuesArray)
End With
End Sub


Sub Delete_Row_NA_Data()
Dim DeleteValue As String
Dim rng As Range

Sheets("data").Select
DeleteValue = "#N/A"
With ActiveSheet
.Range("D100:D1000").AutoFilter Field:=1, Criteria1:=DeleteValue
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete

End With
.AutoFilterMode = False
End With
End Sub

Sub Extend_Stock_Data()


Dim LastRow As Long


With Worksheets("data")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
..Range("b17:g17").AutoFill Destination:=.Range("b17:g" & LastRow) _
, Type:=xlFillDefault

End With

End Sub
 
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 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
Urgent - X and Y Axis Auto Scale for Chart Sandi Charts and Charting in Excel 3 June 9th 06 09:04 AM
XY Chart Improvements For Scientific Data Phil Preen Charts and Charting in Excel 3 October 15th 05 04:33 AM
Changing a chart scale using a formula/macro Doug Charts and Charting in Excel 2 August 10th 05 10:45 PM
Chart Axis Scale Auto Values Moses Bunting Charts and Charting in Excel 1 June 7th 05 11:03 PM


All times are GMT +1. The time now is 11:06 AM.

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"