Plot Graph via VBA, from multiple worksheet. Simple but complex - with examples

aqibi2000

New Member
Joined
Oct 19, 2017
Messages
9
Office Version
  1. 2013
  2. 2010
Platform
  1. Windows
  2. MacOS
Hello, I have a complex but simple request for help.

I have some data I wish to populate onto a graph which has limited axis of:
X axis = -5 to 5
Y axis =-5 to 85

(Please see attached image as an example)

I wish to plot 2 series of co-ordinates onto the graph, with joint line.

In total there are 4 sheets of data, each containing 20 columns of data:
(X1, Y1, and X2, Y2).

After plotting the first row of both co-orrdinates i wish to overwrite the series of data with the next row after 0.5 milli seconds until the specified number of rows is achieved.

Here are some of the things I've looked into:

SeriesCollection(n).Delete

<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">Sub GraphTest()
Dim xaxis As Range
Dim yaxis As Range
Dim fullRange As Range
Dim topcell As Range
Set xaxis = Range("$B$26", Range("$B$26").End(xlDown))
Set yaxis = ActiveSheet.Buttons(Application.Caller).TopLeftCell
Set yaxis = Range(Cells(yaxis.Row, yaxis.Column).Offset(2, 0), Cells(yaxis.Row, yaxis.Column).Offset(2, 0).End(xlDown))
Set topcell = ActiveSheet.Buttons(Application.Caller).TopLeftCell

Set fullRange = Union(xaxis, yaxis)
fullRange
.Select
topcell
.Activate
ActiveSheet
.Shapes.AddChart.Select
ActiveChart
.ChartType = xlLine
ActiveChart
.SetSourceData Source:=fullRange
End Sub()</code>
j2YcJaa.png
[/IMG]
ue9eIAp.png
[/IMG]:(:(
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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