1
在Excel VBA標準的循環是這樣的:如何使用計數器作爲函數中的參數?
dim i as integer
for i = 1 to 100
<do program>
next
end sub
現在,我的問題是:我該如何使用計數器,我作爲該計劃的爭論?
例如:
dim i as integer
for i = 1 to 100
If Range("Ci") = 0 Then
Rows("i:i").Select
Rows.Delete
next
end sub
謝謝馬克,這就像一個魅力工作! – Pieter 2010-11-09 03:32:35
注意事項:如果你真的刪除了行,向後計數就像* For i = 100 to 1 Step -1 *。否則,你會得到你可能不會期望的結果。 – 2010-11-09 16:43:06
@Dick ...或者使用Do..Loop構造,並且不要在刪除時前進,因爲行(i)被刪除後,行(i + 1)將代替行i。 – MikeD 2010-11-10 16:16:16