Creating a graph with multiple series

ireland87

Board Regular
Joined
Jul 22, 2015
Messages
52
Hi

I have got this piece of code to work for one series.

How can i have multiple series?

The data it uses for x and y will be the same columns but I want to have it so it theres two different "system-names" in another column both "system-names" will have a series on the graph

Code:
Sub CreateGraph()

'creating graph
Dim LstRw As Long, crng As Range, x As Range, y As Range
    
LstRw = Sheets("Filter").Range("D" & Rows.Count).End(xlUp).Row
    
Set x = Sheets("Filter").Range("D6:D" & LstRw)
Set y = Sheets("Filter").Range("K6:K" & LstRw)
    
Dim cht As Object
Set cht = ThisWorkbook.Sheets("Chart1")

'Your data range for the chart

'Give chart some data
cht.SeriesCollection(1).XValues = y
cht.SeriesCollection(1).Values = x
  
'Determine the chart type
  cht.ChartType = xlXYScatterLines

'Ensure chart has a title
  cht.HasTitle = True
  
'system name
sysnm = Sheets("Master").Range("B11").Value

'Change chart's title
  cht.ChartTitle.Text = sysnm & " EOD Run Time Analysis"

'Change chart's x-axis
    cht.Axes(xlCategory, xlPrimary).HasTitle = True
    cht.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date"
    
'Change chart's y-axis
    cht.Axes(xlValue, xlPrimary).HasTitle = True
    cht.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Run Time (mins)"
    
    
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I think what needs to happen is some sort of loop.

For Each "system-name"

get the x values from column D if the row contains system-name

then

get the y values from column K if the row contains system-name

do this for for each system-name, creating a new series for each one.

Do people think this is possible???
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,272
Members
449,075
Latest member
staticfluids

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