Change Chart Typewith button

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?
 
D

Debra Dalgleish

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
'==========================
 
D

Debra Dalgleish

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
'===============================
 
Top