Loop to create chart on each worksheet

Human_doing

Board Regular
Joined
Feb 16, 2011
Messages
137
Hi all,

The below code (generated using macro recorder) creates a chart on worksheet '2x', can anyone please correct the code in order to make it loop through all worksheets on a workbook and create a chart on each? It would also be really beneficial if the chart could be placed one cell below the last cell with data on each workbook?

Thanks in advance for any help this would be really helpful,

Code:
[FONT=Arial][SIZE=2]Sub Chart1()[/SIZE][/FONT]
 
[FONT=Arial][SIZE=2]  Range("M1:N10").Select[/SIZE][/FONT]
[SIZE=2][FONT=Arial]  Charts.Add[/FONT][/SIZE]
[SIZE=2][FONT=Arial]  ActiveChart.ChartType = xlColumnClustered[/FONT][/SIZE]
[SIZE=2][FONT=Arial]  ActiveChart.SetSourceData Source:=Sheets("2X").Range("M1:N10"), PlotBy:= _[/FONT][/SIZE]
[SIZE=2][FONT=Arial]      xlColumns[/FONT][/SIZE]
[SIZE=2][FONT=Arial]  ActiveChart.Location Where:=xlLocationAsObject, Name:="2X"[/FONT][/SIZE]
 
 
[SIZE=2][FONT=Arial]End Sub[/FONT][/SIZE]
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,224,602
Messages
6,179,845
Members
452,948
Latest member
UsmanAli786

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