If you are open to a VBA solution, you can use the Workbook.SetLinkOnData
method to call a Sub when the incoming data changes.
I would suggest only responding to changes on the TIME
topic, and copying all relavent data in one go
Based on this data layout
Set up the monitor on the Open event (place this in the ThisWorkbook
module)
Sub Workbook_Open()
Dim wb As Workbook
Dim Links As Variant
Dim i As Long
Set wb = ThisWorkbook
Links = wb.LinkSources(xlOLELinks)
For i = LBound(Links) To UBound(Links)
If Left$(Links(i), 8) = "MT4|TIME" Then
wb.SetLinkOnData Links(i), "MT4_OnUpdate"
End If
Next
End Sub
And code your data handler in a normal module
Sub MT4_OnUpdate()
' DDE Updated TIME, copy data
Dim ws As Worksheet
Dim Source As Range
Dim Dest As Range
Set ws = Worksheets("Your DDE Data Sheet")
With ws
Set Source = ws.Range("A2:E2")
Set Dest = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).Resize(1, Source.Columns.Count)
End With
Dest.Value = Source.Value
End Sub
This will copy cells A2:E2
to the bottom of the Historical data list, each time A2
(time stamp from MT4) changes.
Note: you say in your OP that you want to update every millsecond. This can't happen, because MT4|TIME
is returning a DateTime serial which has a resolution of 1 second. And even if it could happen, that would be way too much data for Excel to handle