How do i plot graphs when the data that i want to plot lies on every alternate column? I tried to use the below code but it gives me two empty graph which im not sure which part of my codes am i missing out or done wrong. If done correctly, it should be graphs something like the one shown in "expected output".
Edited:
The X values are in the 1st column while the y values are 2,4,6,8 etc..
data use for plotting
Expected output
Sub plotgraph()
Dim i As Long, c As Long
Dim shp As Shape
Dim Cht As Chart
Dim rngDB As Range, rngX As Range
Dim Srs As Series
Dim ws As Worksheet
Set ws = Sheets("Data")
Set rngDB = ws.UsedRange
c = rngDB.Columns.Count
Set shp = ws.Shapes.AddChart
Set Cht = shp.Chart
With Cht
For i = 1 To c Step 2 'For every alternate column so in step2
With ws
Set rngX = ws.Range(.Cells(2, i), .Cells(2, i).End(xlDown))
End With
Set Srs = .SeriesCollection.NewSeries
With Srs
.XValues = rngX
End With
Next i
ws.Shapes.AddChart.Select
Cht.ChartType = xlXYScatter
' ActiveChart.SetSourceData Source:=Range("Data!$A:$A")
Cht.Axes(xlValue).Select
Cht.Axes(xlValue).MinimumScale = 6.45
Cht.Axes(xlValue).MinimumScale = 5
Cht.Axes(xlValue).MaximumScale = 6.8
Cht.Axes(xlValue).MaximumScale = 9
Cht.Axes(xlValue).TickLabels.NumberFormat = "0.00E+00"
Cht.Axes(xlCategory, xlPrimary).HasTitle = True
Cht.Axes(xlValue, xlPrimary).HasTitle = True
End With
End Sub
Issue


