September 23, 2019

Get stock data from Exchange at specific intervals automatically

How to get stock data from an Exchange at specific intervals automatically using VBA.
Here’s the complete VBA code:

Option Explicit

Dim myTimer As Date

Sub GetMyData()

Dim lastrow As Long, nextblankrow As Long

myTimer = Now + TimeValue(“00:01:00”)

Sheet1.Range(“B2”).Copy

lastrow = Sheets(“Sheet1”).Range(“G” & Rows.count).End(xlUp).Row

nextblankrow = lastrow + 1

Range(“G” & nextblankrow).PasteSpecial xlPasteValues

ActiveWorkbook.RefreshAll

Application.OnTime myTimer, “GetMyData”

End Sub

Sub StopGettingData()

Application.OnTime myTimer, “GetMyData”, , False

MsgBox “Data Transfer Stopped!”

End Sub

Watch the video below:

One thought on “Get stock data from Exchange at specific intervals automatically

Comments are closed.