Skip to content

Instantly share code, notes, and snippets.

@potass13
Created April 26, 2023 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save potass13/1ec03b93a3fab9611c8e2258a7ac310d to your computer and use it in GitHub Desktop.
Save potass13/1ec03b93a3fab9611c8e2258a7ac310d to your computer and use it in GitHub Desktop.
Option Explicit
Sub Plot_Move()
Dim i As Long
Dim t As Long
Dim PLOT_DATA_NUM As Long
Dim INTERVAL_msec As Long
PLOT_DATA_NUM = 15
INTERVAL_msec = 50
Dim ch_oil As ChartObject
Set ch_oil = Worksheets("Data").ChartObjects(3)
Dim ch_time As ChartObject
Set ch_time = Worksheets("Data").ChartObjects(1)
With ch_oil.Chart
For t = 0 To 200 - PLOT_DATA_NUM
For i = 1 To 6
.SeriesCollection(i).Formula = "=SERIES(" & Range(Cells(9, 4 * i + 25), Cells(9, 4 * i + 25 + 1)).Address(External:=True) & "," & _
Range(Cells(t + 16, 4 * i + 25 + 3), Cells(t + 16 + PLOT_DATA_NUM, 4 * i + 25 + 3)).Address(External:=True) & "," & _
Range(Cells(t + 16, 4 * i + 25 + 2), Cells(t + 16 + PLOT_DATA_NUM, 4 * i + 25 + 2)).Address(External:=True) & "," & i & ")"
Next i
ch_time.Chart.SeriesCollection(2).Formula = "=SERIES(" & Cells(4, 2).Address(External:=True) & "," & _
Cells(t + 16 + PLOT_DATA_NUM, 23).Address(External:=True) & "," & _
Cells(t + 16 + PLOT_DATA_NUM, 25).Address(External:=True) & "," & 2 & ")"
DoEvents
DoEvents
'Application.Wait [Now()] + INTERVAL_msec / 86400000
Next t
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment