Add additional axis to chart using toggle button

enbee

New Member
Joined
Dec 13, 2011
Messages
7
Hi

I need to add an additional Y axis to a line graph and an additional line to go with it using a toggle button. eg: once the user clicks on the toggle button the additional line and axis will appear on the graph then click it again to remove the additional line and axis.

hope this makes sense

Any help is much appreciated

Nick
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
run this macro on the button click (adapt heavily to your situation):
Code:
Sub blah()
With ActiveSheet.ChartObjects("Your Chart name").Chart
  For i = .SeriesCollection.Count To 1 Step -1
    If .SeriesCollection(i).AxisGroup = xlSecondary Then
      .SeriesCollection(i).Delete
      FoundSecondary = True
  End If
    Next i
  If Not FoundSecondary Then
    .SeriesCollection.Add Sheets("Your data sheet name").Range("C4:C15")
    .SeriesCollection(.SeriesCollection.Count).AxisGroup = 2
  End If
End With
End Sub
developed in Excel 2003 so in 2007 and above may not work.
 
Upvote 0

Forum statistics

Threads
1,217,168
Messages
6,135,009
Members
449,904
Latest member
DJ038

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top