Hi!!!
I am using excel 2013
Below is the macro, when I fetched data from web.
What I want is, cell "A1" should be the reference cell for date. So if I changed the date and run the macro, data should be updated from URL.
Is it possible in excel 2013 without macros
Please suggest necessary changes in below code for the same.
Thanks
>>> use code - tags <<<
I am using excel 2013
Below is the macro, when I fetched data from web.
What I want is, cell "A1" should be the reference cell for date. So if I changed the date and run the macro, data should be updated from URL.
Is it possible in excel 2013 without macros
Please suggest necessary changes in below code for the same.
Thanks
>>> use code - tags <<<
Code:
Sub Macro1()
'
' Macro1 Macro
'
'
ActiveWorkbook.Queries.Add Name:="sec_bhavdata_full_16022022", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Csv.Document(Web.Contents(""https://archives.nseindia.com/products/content/sec_bhavdata_full_16022022.csv""),[Delimiter="","", Columns=15, Encoding=1252, QuoteStyle=QuoteStyle.None])," & Chr(13) & "" & Chr(10) & " #""Promoted Headers"" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])," & Chr(13) & "" & Chr(10) & " #""Changed Type"" = Table.TransformColumnTypes(#""Promoted Headers"",{{""SYM" & _
"BOL"", type text}, {"" SERIES"", type text}, {"" DATE1"", type date}, {"" PREV_CLOSE"", type number}, {"" OPEN_PRICE"", type number}, {"" HIGH_PRICE"", type number}, {"" LOW_PRICE"", type number}, {"" LAST_PRICE"", type number}, {"" CLOSE_PRICE"", type number}, {"" AVG_PRICE"", type number}, {"" TTL_TRD_QNTY"", Int64.Type}, {"" TURNOVER_LACS"", type number}, {"" NO_" & _
"OF_TRADES"", Int64.Type}, {"" DELIV_QTY"", type text}, {"" DELIV_PER"", type text}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " #""Changed Type"""
ActiveWorkbook.Worksheets.Add
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=sec_bhavdata_full_16022022;Extended Properties=""""" _
, Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM [sec_bhavdata_full_16022022]")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "sec_bhavdata_full_16022022"
.Refresh BackgroundQuery:=False
End With
End Sub
Last edited by a moderator: