asked on
Sub GetNSEData()
' Download one stock only
Dim DataSheet As Worksheet
Dim qurl As String
Dim nQuery As Name
Application.ScreenUpdating = True
Application.DisplayAlerts = False
Application.Calculation = xlCalculationAutomatic
Set DataSheet = ActiveSheet
Range("C7").CurrentRegion.ClearContents
'construct the URL for the query
qurl = "https://www.nseindia.com/products/dynaContent/common/productsSymbolMapping.jsp?instrumentType=FUTSTK&symbol=YESBANK&expiryDate=30-03-2017&optionType=&strikePrice=&dateRange=3month&fromDate=&toDate=&segmentLink=9&symbolCount=2"
QueryQuote:
With ActiveSheet.QueryTables.Add(Connection:="URL;" & qurl, Destination:=DataSheet.Range("C7"))
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With
'turn calculation back on
Application.DisplayAlerts = True
Range("A1").Select
End Sub