I have posted this on other forum but with no result, hope anyone here can assist me with the code, thank you
Getting Live MT4 forex data
any possible way that i can run the vba and still able to do other task on other workbook?
I have posted this on other forum but with no result, hope anyone here can assist me with the code, thank you
Getting Live MT4 forex data
any possible way that i can run the vba and still able to do other task on other workbook?
Yes, it can be done. I've added a button to make it easier for you to stop the macro in between. Code used
In Module1
In sheet1Code:Option Explicit
Public blnStopUpdate As Boolean
Dim dtmAlertTime As Date
Private Sub EventMacro()
Dim lngLoop As Integer
For lngLoop = 2 To 2500
If Range("Q" & lngLoop) = Range("$L$2") Then
Range("S" & lngLoop).Value = Range("N2").Value
End If
Next lngLoop
DoEvents
If Not blnStopUpdate Then
dtmAlertTime = Now + TimeValue("00:00:05")
Application.OnTime dtmAlertTime, "EventMacro"
End If
End Sub
Sub GetLiveData()
dtmAlertTime = Now + TimeValue("00:00:05") 'Set time (sec) for updating data
Application.OnTime dtmAlertTime, "EventMacro"
End Sub
Private Sub SetTimeNow()
Dim lngLoop As Integer
Application.ScreenUpdating = False
Range("R2").Value = Evaluate("=INT(NOW()/(1/288))*(1/288)+288*(1/288)*(1/288)")
For lngLoop = 1 + 2 To 2500 + 2
Range("R" & lngLoop).Value = Range("R" & lngLoop - 1).Value + Range("U2").Value
Next lngLoop
Columns("S:S").ClearContents
Range("F2").Select
Application.ScreenUpdating = True
End Sub
By the way, the attachment is only meant for MT4 (Meta Trader) users.Code:Private Sub CommandButton1_Click()
Application.Run "'get Live Data_Test.xls'!GetLiveData"
End Sub
Private Sub CommandButton2_Click()
Application.Run "'get Live Data_Test.xls'!SetTimeNow"
End Sub
Private Sub CommandButton3_Click()
blnStopUpdate = True
End Sub