我要使用的鏈接是“https://xxx/xxx/xxx/reporting?start_date=2022-05-15 00&end_date=2022-05-21 00”,而 start_date=Simba1 和 end_date=Simba2
Simba 1 和 simba 2 是日期單元格。
'下載辛巴表'
Sheets("SIMBA Data").Select
Cells.Select
Selection.ClearContents
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://xxx/xxx/xxx/reporting?" _
& "start_date=" & Simba1 _
& "&end_date=" & Simba2 & "", Destination:=Range("$A$1"))
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "1"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
uj5u.com熱心網友回復:
采用Format()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://xxx/xxx/xxx/reporting?" _
& "start_date=" & Format(Simba1, "yyyy-mm-dd") _
& " 00&end_date=" & Format(Simba2, "yyyy-mm-dd") & " 00", _
Destination:=Range("$A$1"))
'...
'...
uj5u.com熱心網友回復:
在蒂姆發布的答案中添加以下內容,解決了我的問題!
Dim Simba1 As Variant
Simba1 = Range("'Report Controls'!$C$1").Value
Dim Simba2 As Variant
Simba2 = Range("'Report Controls'!$C$2").Value
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/479844.html
