Creating multiple column graphs from a range

jacinthn

Board Regular
Joined
Jun 15, 2010
Messages
96
i found a macro i'm trying to modify to create 91 column graphs with the source data based on a range


the below macro creates the graph but isnt selecting the source data correctly

the data ranges from column b-j 2 rows for each month and its 2 months of data

Data layout eg

Series one Series 2 Series 1 Series 2
A B C D
Sale percentage Profit percentage Sale percentage Profit percentage

Dec -2013 Dec 2013 Jan-2014 Jan-2014

44.3% 22.9% 52.8% 44.3%
27.9% 13.% 12.7% 25.8%



is there anyway to modify the below macro to select multiple series for the graphs?

thanks


Sub main()</SPAN>
'variable declaration</SPAN>
Dim i As Long</SPAN>
Dim LastRow As Long</SPAN>
Dim LastColumn As Long</SPAN>
Dim chrt As Chart</SPAN>

LastRow = Sheets("Month over Month").Range("b94:i94").End(xlUp).Row</SPAN>

LastColumn = Sheets("Month over Month").Range("B1").End(xlToRight).Column</SPAN>

For i = 2 To LastRow</SPAN>
Sheets("Sheet2").Select</SPAN>

Set chrt = Sheets("Sheet2").Shapes.AddChart.Chart</SPAN>
chrt.ChartType = xlColumnClustered</SPAN>

With Sheets("Month over Month")</SPAN>
chrt.SetSourceData Source:=.Range(.Cells(i, 1), .Cells(i, LastColumn))</SPAN>
End With</SPAN>

chrt.ChartArea.Left = 1</SPAN>
chrt.ChartArea.Top = (i - 2) * chrt.ChartArea.Height</SPAN>

Next</SPAN>

End Sub</SPAN>
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,216,026
Messages
6,128,363
Members
449,444
Latest member
abitrandom82

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