Edit:
I'm using the following code to create graphs
Dim i As Long
For i = 8 To 10
Dim Start1 As String
Dim End1 As String
Dim Start2 As String
Dim End2 As String
Dim Start3 As String
Dim End3 As String
Dim Start4 As String
Dim End4 As String
Start1 = ThisWorkbook.Worksheets("Test Setup").Range("D" & i)
End1 = ThisWorkbook.Worksheets("Test Setup").Range("E" & i)
Start2 = ThisWorkbook.Worksheets("Test Setup").Range("F" & i)
End2 = ThisWorkbook.Worksheets("Test Setup").Range("G" & i)
Start3 = ThisWorkbook.Worksheets("Test Setup").Range("H" & i)
End3 = ThisWorkbook.Worksheets("Test Setup").Range("I" & i)
Start4 = ThisWorkbook.Worksheets("Test Setup").Range("J" & i)
End4 = ThisWorkbook.Worksheets("Test Setup").Range("K" & i)
Sheets("Data").Select
ActiveSheet.Shapes.AddChart2(240, xlXYScatterLines).Select
ActiveChart.SetSourceData Source:=Range(Start1 & ":" & End1)
ActiveChart.SetSourceData Source:=Range(Start2 & ":" & End2)
ActiveChart.SetSourceData Source:=Range(Start3 & ":" & End3)
ActiveChart.SetSourceData Source:=Range(Start4 & ":" & End4)
ActiveChart.Parent.Cut
Sheets("Sheet5").Select
ActiveSheet.Paste
Next i
End Sub
Running the code give me only 3 line graphs that look like graph A
but only for the range given by this last line of code
ActiveChart.SetSourceData Source:=Range(Start4 & ":" & End4)
If I delete the lines that include Start1 through Start 3 then the graph looks like graph B instead of A.
I've tried separating the code like this
Sheets("Data").Select
ActiveSheet.Shapes.AddChart2(240, xlXYScatterLines).Select
ActiveChart.SetSourceData Source:=Range(Start1 & ":" & End1)
Sheets("Data").Select
ActiveSheet.Shapes.AddChart2(240, xlXYScatterLines).Select
ActiveChart.SetSourceData Source:=Range(Start2 & ":" & End2)
Sheets("Data").Select
ActiveSheet.Shapes.AddChart2(240, xlXYScatterLines).Select
ActiveChart.SetSourceData Source:=Range(Start3 & ":" & End3)
Sheets("Data").Select
ActiveSheet.Shapes.AddChart2(240, xlXYScatterLines).Select
ActiveChart.SetSourceData Source:=Range(Start4 & ":" & End4)
Yet I still get graphs that look like B and not graph A
The Start and End for the ranges come from here
I need help in 2 things:
- I need to get graphs that look like A for all 4 ranges
- I need to know if there's a way to merge the graphs while the
For
function is running or I need to rewrite the code in some other way THanks