標題: [發問] 簡化重複的 for each ... in [打印本頁] 作者: s13030029 時間: 2019-7-25 08:44 標題: 簡化重複的 for each ... in
請問要怎樣簡化下面這段程式嗎????
For Each Abar In Application.CommandBars
If Not Abar.BuiltIn Then Abar.Delete
Next
For Each Bbar In Application.CommandBars
If Not Bbar.BuiltIn Then Bbar.Delete
Next
For Each Cbar In Application.CommandBars
If Not Cbar.BuiltIn Then Cbar.Delete
Next
For Each Dbar In Application.CommandBars
If Not Dbar.BuiltIn Then Dbar.Delete
Next
For Each Ebar In Application.CommandBars
If Not Ebar.BuiltIn Then Ebar.Delete
Next
For Each Fbar In Application.CommandBars
If Not Fbar.BuiltIn Then Fbar.Delete
Next
複製代碼
作者: s13030029 時間: 2019-7-26 09:12
回復 1#s13030029
用陣列的方式,已解決~~~
bbar = Array(bar1, bar2, bar3, bar4, bar5, bar6)
For Each bbar In Application.CommandBars
If Not bbar.BuiltIn Then bbar.Delete
Next