rodneywead
04-22-2011, 08:10 AM
I am using Excel 2010. I am trying to set up a chart macro that I can run once I make a pivot table. I recorded the macro and this is the code I got.
Sub Chart()
'
' Chart Macro
'
' Keyboard Shortcut: Ctrl+q
'
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Range("'Root Cause'!$A$3:$B$17")
End Sub
When I try and run it on other charts it gives me an error message if the chart range is not $A$3:$B$17. How do I set this up so I can run it no matter what the range of the chart is?
Thanks,
Rodney
Sub Chart()
'
' Chart Macro
'
' Keyboard Shortcut: Ctrl+q
'
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Range("'Root Cause'!$A$3:$B$17")
End Sub
When I try and run it on other charts it gives me an error message if the chart range is not $A$3:$B$17. How do I set this up so I can run it no matter what the range of the chart is?
Thanks,
Rodney