• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

hi plz help me on this macro

vjvijay88

New Member
Code:
Sub Macro1()
'
' Macro1 Macro
'

'
    ActiveWorkbook.Queries.Add Name:="Sheet1 (2)", Formula:= _
        "let" & Chr(13) & "" & Chr(10) & "    Source = Excel.Workbook(Web.Contents(""http://www.nseindia.com/content/fo/fii_stats_01-Aug-2016.xls""), null, true)," & Chr(13) & "" & Chr(10) & "    Sheet2 = Source{[Name=""Sheet1""]}[Data]," & Chr(13) & "" & Chr(10) & "    #""Promoted Headers"" = Table.PromoteHeaders(Sheet2)," & Chr(13) & "" & Chr(10) & "    #""Promoted Headers1"" = Table.PromoteHeaders(#""Promoted Headers"")," & Chr(13) & "" & Chr(10) & "    #""Promoted Headers2"" = Table.PromoteHeaders(#""Promote" & _
        "d Headers1"")," & Chr(13) & "" & Chr(10) & "    #""Removed Bottom Rows"" = Table.RemoveLastN(#""Promoted Headers2"",13)" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & "    #""Removed Bottom Rows"""
    Sheets.Add After:=ActiveSheet
    With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
        "OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=""Sheet1 (2)""" _
        , Destination:=Range("$A$1")).QueryTable
        .CommandType = xlCmdSql
        .CommandText = Array("SELECT * FROM [Sheet1 (2)]")
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = False
        .ListObject.DisplayName = "Sheet1__2"
        .Refresh BackgroundQuery:=False
    End With
    Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
    ActiveSheet.ListObjects("Sheet1__2").Name = "NSE"
End Sub




if i run macro again its shows error that name is already exist and another thing that i need to download this i daily date wise so i have to input date so i can get this data today and previous day data together , kindly any one help me on this i am not so good in vba , i am looking this for more than a month
 

Attachments

  • Download file from URL using VBA (for GillB at chandoo.org).xlsm
    30.7 KB · Views: 0
Back
Top