假设:
Sheet1的Sub A从sheet2和sheet3复制数据 Sheet2的Sub B使用编码从网站X中检索数据 Sheet3的Sub C使用编码从网站Y中检索数据
我添加了一个命令按钮来刷新Sheet1输出,但它不起作用,因为我无法编码同时刷新Sheet2和Sheet3中的数据。
enter code here
Sub A()
B '
C ' want to call it for refreshing data first but it show error on msgbox that destination range is not on the samw worksheet that the Query table is being created on.
ActiveWorkbook.Sheets("Sheet2").Range("A8").EntireRow.Copy Destination:=ActiveWorkbook.Sheets("Sheet1").Range("A1")
ActiveWorkbook.Sheets("Sheet3").Range("A2").EntireRow.Copy Destination:=ActiveWorkbook.Sheets("Sheet1").Range("A2")
End Sub
Sub B()
With ThisWorkbook.Sheets("Sheet2").QueryTables.Add(Connection:= _
"URL;http://www.reuters.com/finance/commodities", _
Destination:=Range("$A$1"))
.RefreshStyle = xlOverwriteCells
.Refresh
End With
End Sub
Sub C()
With ThisWorkbook.Sheets("Sheet3").QueryTables.Add(Connection:= _
"URL;http://www.reuters.com/finance/markets/indices", _
Destination:=Range("$A$1"))
.RefreshStyle = xlOverwriteCells
.Refresh
End With
End Sub
请帮忙