Change Chart Typewith button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to change ALL of my chart from a bar graph
to an X-Y or line chart? I have 27 charts on thier on
sheet. I want to be able to have a button that runs a
macro that will change all the chart to bar, then another
to change it back to a line chart?

Any thought?
 
The following macros will change all embedded charts on the active sheet:

'=======================
Sub ChartsToLine()
Dim chObj As ChartObject
For Each chObj In ActiveSheet.ChartObjects
chObj.Chart.ChartType = xlLine
Next
End Sub
'===================================
Sub ChartsToColumn()
Dim chObj As ChartObject
For Each chObj In ActiveSheet.ChartObjects
chObj.Chart.ChartType = xlColumnClustered
Next
End Sub
'==========================
 
Change the code to the following:
'======================
Sub ChartsToLine()
Dim ch As Chart
For Each ch In ActiveWorkbook.Charts
ch.ChartType = xlLine
Next
End Sub
'================================
Sub ChartsToColumn()
Dim ch As Chart
For Each ch In ActiveWorkbook.Charts
ch.ChartType = xlColumnClustered
Next
End Sub
'===============================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top