Avatar of vijay vj
vijay vj
Flag for India

asked on 

Need To remove Extra Column adding, while downloading through vba

Dear sir,

 I have a vba  code where it will download the data from web to excel , but the problem is that while downloading in my worksheet extra columns are adding , my download button is moving column wise, kindly help me to correct my vba.

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
'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"
             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

End Sub

Open in new window

Microsoft ExcelVBAMicrosoft Office

Avatar of undefined
Last Comment

8/22/2022 - Mon