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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,865
Members
449,052
Latest member
Fuddy_Duddy

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