xyPlot automated series addition

PossiblyNot

New Member
Joined
Jul 11, 2014
Messages
5
Hi all,

I'm currently making an excel workbook where a user inputs a range of data which gets processed and reorganised into a table like the one below found in the "Intermediate" sheet in the workbook. There can be anything from 1 series to dozens, even hundreds.

NameY1Y2X1X2
Test1211911
Test211.65.422
Test32.82.633
Test428.411.644
Test565.42355

<tbody>
</tbody>


I'm hoping to plot a simple scatter plot to plot vertical ranges (y1 and y2) using VBA to automate the entire process

my current stab at the code as follows

Code:
Sub BioStratPlotter()

Charts.Add


ActiveChart.ChartType = xlXYScatterLinesNoMarkers
ActiveChart.SeriesCollection.NewSeries
    
Dim i As Variant


Set i.Value = 3
  
  Do While i.Value <> ""
 
 For i = 3 To 48
     
   'each row is a different series, with each row as such: [Name], [Y value], [Y value], [X value], [X value]
   ActiveChart.SeriesCollection(6).XValues = "=Intermediate!R(i)$C5:IntermediateR(i)$C6"
    ActiveChart.SeriesCollection(6).Values = "=Intermediate!R(i)$C3:IntermediateR(i)$C4"
    ActiveChart.SeriesCollection(6).Name = "=Intermediate!R(i)$C2"
    ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="BioStrat"
    'Options for the graph
    ActiveChart.Axes(xlValue).MajorGridlines.Select
    With ActiveChart.Axes(xlValue)
        'Scale is from 0Mya to 65.4 Mya (End-Cretaceous)
        .MinimumScale = 0
        .MaximumScale = 65.4
        .MinorUnitIsAuto = True
        .MajorUnit = 10
        .Crosses = xlAutomatic
        'X-axis is plotting downwards
        .ReversePlotOrder = True
        .ScaleType = xlAutomatic
        .DisplayUnit = xlNone
    End With


 'loop statement clicks down one row
Next i


Loop
            
End Sub

the current error is a 424 error (object required) however, I sense my logic is flawed regardless.

What have I royally fudged?

Cheers

PossiblyNot
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,214,591
Messages
6,120,428
Members
448,961
Latest member
nzskater

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