你好,我有樹下一個碼一個什麼樣的問題是VBA什麼是VBA中更高效地爲行,在未來的樹代碼移動
更有效選項1:
While fin
if activecell.value = "Comp"
' do something
' I use some many time the value of the activecell or the line
' im actually
end if
activecell.offset(1,0).activate
loop
選項2 :
dim i as long
i=0
While fin
if activecell.offset(i,0).value = "Comp"
' do something
' I use some many time the value of the activecell or the line
' im actually
end if
i = i + 1
loop
方案3:「因爲我使用了一些很多次實際行我不知道 」如果可能不如趁這個值的變量
dim i as long
dim x as string
i=0
While fin
x = activecell.offset(i,0)
if x = "Comp"
' do something
' I use some many time the value of the activecell or
'the line im actually
end if
i = i + 1
loop
在此先感謝您的幫助
PD爲我所有的代碼
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
Application.DisplayAlerts = False
你試過了嗎?你發現了什麼? –
嘿是的,我嘗試了它的速度更快,但我現在用這種方法練習更多對我來說並不自然。非常感謝您的幫助 –