ok - here is the code. You will see 2 products with different data. SUMIF's
are used to populate data range for graphs which are working fine. You will
notice two charts with numbers to change the scale. Chart 32 works fine and
changes depending on which product is selected. Chart 60, however is the one
which changes during the macro to the correct scale, but once it steps to
Range("A8").Select, the scale reverts back to the original scale. This is the
part I don't understand...
Sub Group_Selector_and_Line_Graph_Update()
If Range("B6").Value = "Product 1" Then
Range("A8").Select
ActiveSheet.Outline.ShowLevels RowLevels:=2
Rows("47:58").Select
On Error Resume Next
Selection.Rows.Ungroup
Rows("64:75").Select
On Error Resume Next
Selection.Rows.Ungroup
Rows("81:92").Select
On Error Resume Next
Selection.Rows.Ungroup
Application.Goto Reference:="P1"
Selection.Copy
Sheets("Portfolio Graph").Select
Range("B47").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Rows("52:58").Select
On Error Resume Next
Selection.Rows.Group
Rows("69:75").Select
On Error Resume Next
Selection.Rows.Group
Rows("86:92").Select
On Error Resume Next
Selection.Rows.Group
Range("A8").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveSheet.ChartObjects("Chart 32").Activate
ActiveChart.Axes(xlValue).MajorGridlines.Select
With ActiveChart.Axes(xlValue)
.MinimumScale = 2000000
.MaximumScale = 3000000
.MinorUnit = 40000
.MajorUnit = 200000
.Crosses = xlCustom
.CrossesAt = 2000000
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Range("A8").Select
ActiveSheet.ChartObjects("Chart 60").Activate
ActiveChart.Axes(xlValue).MajorGridlines.Select
With ActiveChart.Axes(xlValue)
.MinimumScale = 0
.MaximumScale = 10000000
.MinorUnit = 200000
.MajorUnit = 2000000
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Range("A8").Select
ElseIf Range("B6").Value = "Product 2" Then
ActiveSheet.Outline.ShowLevels RowLevels:=2
Rows("47:58").Select
On Error Resume Next
Selection.Rows.Ungroup
Rows("64:75").Select
On Error Resume Next
Selection.Rows.Ungroup
Rows("81:92").Select
On Error Resume Next
Selection.Rows.Ungroup
Application.Goto Reference:="P2"
Selection.Copy
Sheets("Portfolio Graph").Select
Range("B47").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Rows("52:58").Select
On Error Resume Next
Selection.Rows.Group
Rows("69:75").Select
On Error Resume Next
Selection.Rows.Group
Rows("86:92").Select
On Error Resume Next
Selection.Rows.Group
Range("A9").Select
ActiveSheet.Outline.ShowLevels RowLevels:=1
ActiveSheet.ChartObjects("Chart 32").Activate
ActiveChart.Axes(xlValue).MajorGridlines.Select
With ActiveChart.Axes(xlValue)
.MinimumScale = 9000000
.MaximumScale = 13500000
.MinorUnitIsAuto = True
.MajorUnit = 1000000
.Crosses = xlCustom
.CrossesAt = 9000000
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Range("A8").Select
ActiveSheet.ChartObjects("Chart 60").Activate
ActiveChart.Axes(xlValue).MajorGridlines.Select
With ActiveChart.Axes(xlValue)
.MinimumScale = 0
.MaximumScale = 40000000
.MinorUnit = 200000
.MajorUnit = 5000000
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Range("A8").Select
nd If
End Sub