troubleshooting Question

Need To remove Extra Column adding, while downloading through vba

Avatar of vijay vj
vijay vjFlag for India asked on
Microsoft ExcelVBAMicrosoft Office
1 Comment1 Solution100 ViewsLast Modified:
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
  
        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
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros