Combining charts using VBA

Kvin

New Member
Joined
Apr 3, 2012
Messages
3
Hi,

I was wondering if you could help me with a piece of VBA that I wrote picking pieces from different websites (I have 0 exp. with VBA).
My data has two columns: Column A is stock price and Column B is option position, there are 360 rows of data in both columns.
Now I want to produce a Scatter chart with X axis having values (1,2,3....360) and Y axis has stock price (series 1) and option position (series 2). As you can see I want a delay between each plot after each x value and hence Im using VBA instead I would have directly done it using excel. Can you help please... below is what I has written so far... this works for columns but scatter plot does not work... Many thanks


+++++++++++++++++++++++++++++++
Sub Doublecharts()
Dim chart1 As ChartObject
Dim chart2 As ChartObject

Dim i As Integer
Dim j As Integer

Set chart1 = ActiveSheet.ChartObjects.Add(Left:=100, Top:=50, _
Width:=400, Height:=300)

Set chart2 = ActiveSheet.ChartObjects.Add(Left:=500, Top:=50, _
Width:=400, Height:=300)

chart1.Chart.ChartType = xlColumnClustered

chart2.Chart.ChartType = xlXYScatterSmoothNoMarkers

For j = 1 To 2
For i = 2 To 6

chart1.Chart.SetSourceData Source:=Sheets("sheet1").Range(Sheets("sheet1").Cells(2, 1), Sheets("sheet1").Cells(i, 2)), PlotBy:=xlColumns
chart2.Chart.SetSourceData Source:=Sheets("sheet1").Range(Sheets("sheet1").Cells(2, 1), Sheets("sheet1").Cells(i, j)), PlotBy:=xlColumns

Application.Wait (Now + (1 / (24 * 60 * 60#)))

Next i
Next j

End Sub
+++++++++++++++++++++++++++++++
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,224,591
Messages
6,179,768
Members
452,940
Latest member
rootytrip

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