软件: EXCEL VBA
版本: office 365
请问我要将https://goodinfo.tw/StockInfo/EquityDistributionClassHis.asp?STOCK_ID=3049中的3049改为sheet(Company)中的储存格B2,
试了""https://goodinfo.tw/StockInfo/EquityDistributionClassHis.asp?STOCK_ID="" &
Sheets("Company").Range("B2").Value,VBA说语法错误,请问版上高手是否能帮忙解惑?
Application.CutCopyMode = False
ActiveWorkbook.Queries.Add Name:="Table 3", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " 来源 =
Web.Page(Web.Contents(""https://goodinfo.tw/StockInfo/EquityDistributionClassHis.asp?STOCK_ID=3049"")),"
& Chr(13) & "" & Chr(10) & " Data3 = 来源{3}[Data]," & Chr(13) & "" &
Chr(10) & " 已变更类型 = Table.TransformColumnTypes(Data3,{{""周别"", type
text}, {""统计 日期"", type date}, {""当月股价 收盘"", type number}, {""当月股
价 涨跌 (元)"", type number}, {""当月股价 涨跌 (%)"", type number}, {""各持股
等级股东之持股比例(%) 10张 以下"", type number" & _
"}, {""各持股等级股东之持股比例(%) 10至 50张"", type number}, {""各持
股等级股东之持股比例(%) 50至 100张"", type number}, {""各持股等级股东之持股比
例(%) 100至 200张"", type number}, {""各持股等级股东之持股比例(%) 200至 400张
"", type number}, {""各持股等级股东之持股比例(%) 400至 800张"", type number},
{""各持股等级股东之持股比例(%) 800至 1千张"", type number}, {""各持股等级股东
之持股比例(%) 超过 1千张"", type number}})" & Chr(13) & "" & Chr(10) & "in" &
Chr(13) & "" & Chr(10) & " 已变更类型" & _
""
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data
Source=$Workbook$;Location=""Table 3"";Extended Properties=""""" _
, Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdSql
.CommandText = Array("SELECT * FROM [Table 3]")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_3"
.Refresh BackgroundQuery:=False
End With
End Sub