Create graph with data from 100 sheets - macro and loop?

Trincazz

New Member
Joined
Mar 5, 2019
Messages
2
I have a data set with individual measurements of over 100 pieces - each in a single sheet.
I need to create line chart with all data plotted in a single graph.
The name of each sheet is in cell J1
Y-Axis range is J2:J256
X-Axis range is C2:C256
How can I create a marco which automatically plots all data in one graph? Any ideas?

I was thinking of recording macro by plotting graph from 1 of the sheet and then create a loop with recorded macro which creates plots on the same graph with all the multiple sheet data? Can anyone help :)
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Worf

Well-known Member
Joined
Oct 30, 2011
Messages
4,183
Hello

Code:
Sub Trcz()
Dim ch As Shape, ws As Worksheet, sn%
Set ch = ActiveSheet.Shapes.AddChart2(240, xlXYScatterLines)
ch.Chart.HasTitle = 0
For Each ws In ActiveWorkbook.Worksheets
    ch.Chart.SeriesCollection.NewSeries
    sn = ch.Chart.FullSeriesCollection.Count
    ch.Chart.FullSeriesCollection(sn).Name = ws.Name
    ch.Chart.FullSeriesCollection(sn).XValues = "=" & ws.Name & "!$c$2:$c$10"
    ch.Chart.FullSeriesCollection(sn).Values = "=" & ws.Name & "!$j$2:$j$10"
Next
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,601
Messages
5,838,300
Members
430,537
Latest member
Antonio11

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
Top