hello,
i am having a little trouble with some graphing.. in a previous post, i had posted this code to create a graph using arrays:
this works... sort of.. ie:
it creates a graph with teh same scale on the x and y axes. i want the scale on the x axis to go from 0 to 6000, incremements of 1000. this is fine. the problem is that it uses the same scale on the y axis.. i want the scale to go from 0 to 2 (possibly in increments of 0.2).. but it goes from 0 to 6000! so you can't really see the graph.. when i manually change teh scale for the y axis, the graph is fine.
i recorded a macro to change the scale.. and added that code to the method (after the last line of the above code- before the "end sub"). but it doesn't work either. actually, it worked once, and then never again!
this is the full code with the recorded macro lines added:
any ideas on how can i set the scale properly?
thanks!
i am having a little trouble with some graphing.. in a previous post, i had posted this code to create a graph using arrays:
Code:
Sub graph(ByRef xvals() As Double, ByRef yvals() As Double, gsoffset As Double)
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
Dim MyNewSrs As Series
Set MyNewSrs = ActiveChart.SeriesCollection.NewSeries
With MyNewSrs
.Name = "Fred"
.Values = yvals
.XValues = xvals
End With
End Sub
this works... sort of.. ie:
it creates a graph with teh same scale on the x and y axes. i want the scale on the x axis to go from 0 to 6000, incremements of 1000. this is fine. the problem is that it uses the same scale on the y axis.. i want the scale to go from 0 to 2 (possibly in increments of 0.2).. but it goes from 0 to 6000! so you can't really see the graph.. when i manually change teh scale for the y axis, the graph is fine.
i recorded a macro to change the scale.. and added that code to the method (after the last line of the above code- before the "end sub"). but it doesn't work either. actually, it worked once, and then never again!
this is the full code with the recorded macro lines added:
Code:
Sub graph(ByRef xvals() As Double, ByRef yvals() As Double, gsoffset As Double)
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
Dim MyNewSrs As Series
Set MyNewSrs = ActiveChart.SeriesCollection.NewSeries
With MyNewSrs
.Name = "Fred"
.Values = yvals
.XValues = xvals
End With
ActiveChart.Axes(xlValue).MajorGridlines.Select
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = 0
.MaximumScale = gsoffset
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Sub
any ideas on how can i set the scale properly?
thanks!