您好,我有一个问题,下一个代码树在 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 FOR我所有的代码
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
Application.DisplayAlerts = False