When I run my code first time after opening excel I get updated and correct data from website but after that I get the same data when I run the code even after 1 hour. the website data change in every 5 minute interval.
I am using excel 2019. I have downloaded the json converter bas file from github, (https://github.com/Malekai/Downloading-Data/blob/master/population_data.json).
The code is here....
Sub N_Test_33()
Dim req As New MSXML2.XMLHTTP60
Dim URL As String, ws As Worksheet
Dim json As Object, r, r1 As String, i, j As Integer
Set ws = ThisWorkbook.Worksheets("Sheet3")
URL = "https://www.nseindia.com/api/option-chain-indices?symbol=BANKNIFTY"
req.Open "GET", URL, False
req.send
r = req.responseText
Set json = JsonConverter.ParseJson(r)
ws.Range("A1").Value = json("filtered")("data")(62)("strikePrice")
ws.Range("A2").Value = json("filtered")("data")(62)("CE")("openInterest")
ws.Range("A3").Value = json("filtered")("data")(62)("PE")("openInterest")
End Sub
The code has to be tested between Mon-Friday, 9:30AM to 3:30PM in Indian timing.