Dear All,
I have linked NSE and BSE websites for pulling real time prices for the day.
In a single excel workbook i have created two VBA module's , one for NSE website and the other one is for BSE website.
I can see any one module only running properly at one time , however i want both the module to run at the same time in my single excel worksheet. Also i can see it is talking around 30 mins to fetch the prices from the website for around 2000 scripts. I want the price fetching process should be with the maximum span of 2-3 mins for both the Module at the same time.
Kindly have a look on this and i request you to advise me for the below two issues which i am facing:-
1. Both the modules are not running properly at the same time in a same worksheet or different worksheet of single workbook.
2. The process is running very slow and taking too much of time.
I want your advise on making both the module to run at the same time in a single worksheet with in the time span of 2-3 mins and fetch prices for around 2000 scripit codes / ID's
Thank you in advance for your help. Really appreciate your time and consideration.
Please find the VBA codings below:-
Module 1 - BSE Webiste
Public Function getBSEData(ScriptCode As String)
URL = "http://www.bseindia.com/stock-share-price/SiteCache/EQHeaderData.aspx?text=" & ScriptCode
Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "GET", URL, False
xmlHttp.setRequestHeader "Content-Type", "text/JSON"
xmlHttp.send
Debug.Print xmlHttp.responseText
getBSEData = xmlHttp.responseText
'jsonString = xmlHttp.responseText
'Set sc = CreateObject("ScriptControl"): sc.Language = "JScript"
'Set jsonDecode = sc.Eval("(" + jsonString + ")")
'Debug.Print jsonDecode.Data(1).lastPrice
End Function
Public Function processData(inputInfo As String, wh As Integer)
Dim splitData() As String
splitData() = Split(inputInfo, ",")
Debug.Print UBound(splitData)
Debug.Print splitData(UBound(splitData) - wh + 1)
processData = splitData(UBound(splitData) - wh + 1)
End Function
Module 2 - Nse Website
Public Function getNSEData(scripID As String)
URL = "http://www.nseindia.com/live_market/dynaContent/live_watch/get_quote/ajaxGetQuoteJSON.jsp?symbol=" & scripID
Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "GET", URL, False
xmlHttp.setRequestHeader "Content-Type", "text/JSON"
xmlHttp.send
Debug.Print xmlHttp.responseText
getNSEData = xmlHttp.responseText
'jsonString = xmlHttp.responseText
'Set sc = CreateObject("ScriptControl"): sc.Language = "JScript"
'Set jsonDecode = sc.Eval("(" + jsonString + ")")
'Debug.Print jsonDecode.Data(1).lastPrice
End Function
I have linked NSE and BSE websites for pulling real time prices for the day.
In a single excel workbook i have created two VBA module's , one for NSE website and the other one is for BSE website.
I can see any one module only running properly at one time , however i want both the module to run at the same time in my single excel worksheet. Also i can see it is talking around 30 mins to fetch the prices from the website for around 2000 scripts. I want the price fetching process should be with the maximum span of 2-3 mins for both the Module at the same time.
Kindly have a look on this and i request you to advise me for the below two issues which i am facing:-
1. Both the modules are not running properly at the same time in a same worksheet or different worksheet of single workbook.
2. The process is running very slow and taking too much of time.
I want your advise on making both the module to run at the same time in a single worksheet with in the time span of 2-3 mins and fetch prices for around 2000 scripit codes / ID's
Thank you in advance for your help. Really appreciate your time and consideration.
Please find the VBA codings below:-
Module 1 - BSE Webiste
Public Function getBSEData(ScriptCode As String)
URL = "http://www.bseindia.com/stock-share-price/SiteCache/EQHeaderData.aspx?text=" & ScriptCode
Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "GET", URL, False
xmlHttp.setRequestHeader "Content-Type", "text/JSON"
xmlHttp.send
Debug.Print xmlHttp.responseText
getBSEData = xmlHttp.responseText
'jsonString = xmlHttp.responseText
'Set sc = CreateObject("ScriptControl"): sc.Language = "JScript"
'Set jsonDecode = sc.Eval("(" + jsonString + ")")
'Debug.Print jsonDecode.Data(1).lastPrice
End Function
Public Function processData(inputInfo As String, wh As Integer)
Dim splitData() As String
splitData() = Split(inputInfo, ",")
Debug.Print UBound(splitData)
Debug.Print splitData(UBound(splitData) - wh + 1)
processData = splitData(UBound(splitData) - wh + 1)
End Function
Module 2 - Nse Website
Public Function getNSEData(scripID As String)
URL = "http://www.nseindia.com/live_market/dynaContent/live_watch/get_quote/ajaxGetQuoteJSON.jsp?symbol=" & scripID
Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHttp.Open "GET", URL, False
xmlHttp.setRequestHeader "Content-Type", "text/JSON"
xmlHttp.send
Debug.Print xmlHttp.responseText
getNSEData = xmlHttp.responseText
'jsonString = xmlHttp.responseText
'Set sc = CreateObject("ScriptControl"): sc.Language = "JScript"
'Set jsonDecode = sc.Eval("(" + jsonString + ")")
'Debug.Print jsonDecode.Data(1).lastPrice
End Function