Here's my challenge:
I have 100 sheets in my workbook that are all identical in layout but contain unique information within each sheet, all based on the same parameters. I've got cells in B14:B18 that contain label information (Earnings by Outlet) and cells in F14:18 that contain numeric (financial) information.
I'm looking to create a pie chart on each sheet in the workbook containing the data from those sheets through a macro. I also am hoping to automate the sizing and positioning of these charts within each sheet. Any ideas? Here's what I have so far:
Sub Pie_Chart()
'
' Pie_Chart Macro
' Makes pie chart from Earnings By Outlet Data.
'
' Keyboard Shortcut: Option+Cmd+Shift+P
'
Range("H24").Select
Range("B14:B18,F14:F18").Select
Range("F14").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlPie
ActiveChart.SetSourceData Source:=Range( _
"'Sheet1'!$B$14:$B$18,'Sheet1'!$F$14:$F$18")
ActiveChart.ApplyLayout (4)
ActiveChart.ClearToMatchStyle
ActiveChart.ChartStyle = 20
ActiveChart.ClearToMatchStyle
ActiveSheet.Shapes("Chart 9").IncrementLeft -306.4
ActiveSheet.Shapes("Chart 9").IncrementTop 93.6
ActiveSheet.Shapes("Chart 9").ScaleWidth 1.2577777778, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes("Chart 9").ScaleHeight 0.8333333333, msoFalse, _
msoScaleFromTopLeft
Range("J28").Select
End Sub
I have 100 sheets in my workbook that are all identical in layout but contain unique information within each sheet, all based on the same parameters. I've got cells in B14:B18 that contain label information (Earnings by Outlet) and cells in F14:18 that contain numeric (financial) information.
I'm looking to create a pie chart on each sheet in the workbook containing the data from those sheets through a macro. I also am hoping to automate the sizing and positioning of these charts within each sheet. Any ideas? Here's what I have so far:
Sub Pie_Chart()
'
' Pie_Chart Macro
' Makes pie chart from Earnings By Outlet Data.
'
' Keyboard Shortcut: Option+Cmd+Shift+P
'
Range("H24").Select
Range("B14:B18,F14:F18").Select
Range("F14").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlPie
ActiveChart.SetSourceData Source:=Range( _
"'Sheet1'!$B$14:$B$18,'Sheet1'!$F$14:$F$18")
ActiveChart.ApplyLayout (4)
ActiveChart.ClearToMatchStyle
ActiveChart.ChartStyle = 20
ActiveChart.ClearToMatchStyle
ActiveSheet.Shapes("Chart 9").IncrementLeft -306.4
ActiveSheet.Shapes("Chart 9").IncrementTop 93.6
ActiveSheet.Shapes("Chart 9").ScaleWidth 1.2577777778, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes("Chart 9").ScaleHeight 0.8333333333, msoFalse, _
msoScaleFromTopLeft
Range("J28").Select
End Sub