如果你總是有相同數量的潛在呼叫(即14確定)。你可以做
Sub batch_import()
with Application
Call Import_NJ
.StatusBar = "Progress: " & Format(1/14, "0%")
Call Import_NY
.StatusBar = "Progress: " & Format(2/14, "0%")
Call Import_MD
.StatusBar = "Progress: " & Format(3/14, "0%")
Call Import_VA
.StatusBar = "Progress: " & Format(4/14, "0%")
Call Import_WV
.StatusBar = "Progress: " & Format(5/14, "0%")
Call Import_PA
.StatusBar = "Progress: " & Format(6/14, "0%")
Call Import_KY
.StatusBar = "Progress: " & Format(7/14, "0%")
Call Import_TN
.StatusBar = "Progress: " & Format(8/14, "0%")
Call Import_IN
.StatusBar = "Progress: " & Format(9/14, "0%")
Call Import_IA
.StatusBar = "Progress: " & Format(10/14, "0%")
Call Import_MI
.StatusBar = "Progress: " & Format(11/14, "0%")
Call Import_MO
.StatusBar = "Progress: " & Format(12/14, "0%")
Call Import_IL
.StatusBar = "Progress: " & Format(13/14, "0%")
Call Import_LW
.StatusBar = "Progress: " & Format(14/14, "0%")
.StatusBar =null
end with
End Sub
你是否想要進度條在Import_ * sub或者每次調用之間更新? –
你有14個電話,每次通話後你可以增加一個變量1/14,如:'x = x + 1/14'。最後達到1.你可以顯示'x',但是你想要的。 (你可以簡單地使用debug.print,或者如果你需要enduser的東西,你可以在用戶表單中使用一個欄) – Tehscript
也許有點先進的VBA的東西(涉及類,模塊屬性,默認實例和工廠方法),但一個*實際*可重用,靈活,可取消和好看的進度指標形式在VBA中完全可行;請參閱[這裏](https://codereview.stackexchange.com/q/87818/23788)。 –