PDA

View Full Version : [SOLVED] min value



asdzxc
08-26-2014, 07:01 PM
Lw = Range("b2").End(xlDown).Row
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).MinimumScale = Application.Min(Range("b2:B" & Lw))
what's wrong with the code below
ActiveChart.Axes(xlValue).MinimumScale = Application.Min(Range("b2:B" & Lw))

mancubus
08-26-2014, 11:41 PM
chart must be selected before running the code.
if that's the case, what error message did you get?

worked for me:


With ActiveChart.Axes(xlValue)
.MinimumScale = Application.Min(Range("B2:B" & Lw))
.MaximumScale = Application.Max(Range("B2:B" & Lw))
End With

mancubus
08-27-2014, 12:03 AM
and you dont need to select the chart....



With Sheets("Sheet1").ChartObjects("Chart 1").Chart.Axes(xlValue)
.MinimumScale = Application.Min(Range("B2:B" & Lw))
End With


modify the sheet and chart object names.

asdzxc
08-27-2014, 01:12 AM
chart must be selected before running the code.
if that's the case, what error message did you get?

worked for me:


With ActiveChart.Axes(xlValue)
.MinimumScale = Application.Min(Range("B2:B" & Lw))
.MaximumScale = Application.Max(Range("B2:B" & Lw))
End With

not working

Lw = Range("b2").End(xlDown).Row
Range("A2:I" & Lw).Select
Set cht1 = ActiveSheet.Shapes.AddChart
cht1.Chart.ChartType = xlLineMarkers
cht1.Chart.Location xlLocationAsNewSheet
ActiveChart.ChartArea.Select
ActiveChart.PlotArea.Select

Dim ValuesArray(), SeriesValues As Variant
Dim Ctr As Integer, TotCtr As Integer
With ActiveChart
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

ActiveChart.FullSeriesCollection(5).Select
ActiveChart.FullSeriesCollection(2).Delete
ActiveChart.FullSeriesCollection(2).Delete
ActiveChart.FullSeriesCollection(2).Delete
ActiveChart.FullSeriesCollection(2).Delete
ActiveChart.FullSeriesCollection(2).Delete
ActiveChart.FullSeriesCollection(2).Delete

With ActiveChart.Axes(xlValue)
.MinimumScale = Application.Min(Range("B2:B" & Lw))
.MaximumScale = Application.Max(Range("B2:B" & Lw))
End With
End With
End Sub

Bob Phillips
08-27-2014, 01:21 AM
Why not post your workbook and tell us iun what way it doesn't work, it errors, scale not correct, what?

asdzxc
08-27-2014, 02:22 AM
posted.
Book2.xlsm

Bob Phillips
08-28-2014, 12:41 AM
No, you told us the name but didn't link it. Go to Advanced>Manage Files.

asdzxc
08-28-2014, 03:10 AM
No, you told us the name but didn't link it. Go to Advanced>Manage Files.

asdzxc
08-28-2014, 03:18 AM
Book2.xlsm attached

asdzxc
08-28-2014, 11:54 PM
SOLVED