我想刷新我的工作簿,然後在單元上運行檢查,如果值> 0顯示一條消息,則代碼我看起來正確且邏輯性強,但刷新是在檢查值之後完成的,我試圖把它們分成單獨的宏並按順序調用它們,但刷新後仍然運行。不確定是否值得注意刷新涉及刷新到SQL DB的數據連接。Excell RefreshAll在其他宏之後運行
這是兩個宏我都不得不時刻:
Sub RefreshMacro()
ActiveWorkbook.RefreshAll
Sheets("Execution").Select
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
Sheets("Traffic Lights").Select
ActiveWorkbook.RefreshAll
End Sub
Sub ErrorMessage()
If Sheets("Traffic Lights").Range("G2").Value > "0" Then
MsgBox "Error with data!" & vbCr &
"Please Note There is an issue with the data" & vbCr &
"See Traffic Lights for more details!", vbOKOnly + vbExclamation,
"Red Traffic Lights"
End If
End Sub
當你一步通過它它工作? –
是的,如果我剎車後刷新它的工作 –
看看http://stackoverflow.com/questions/22083668/wait-until-activeworkbook-refreshall-finishes-vba –