Hello I have a question what of the tree next codes is more efficient in VBA
Option 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
Option 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
Option 3: ‘because I use some many times the actual row I dont know
‘If maybe is better to take that value to a variable
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
Thanks In advance for your help
PD FOr all the codes I have
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
Application.DisplayAlerts = False
Option 4, i.e. the Option 4 that you didn’t write, is much more efficient than your options 1-3. Don’t bother activating or offsetting any cells. Just load your data to a Variant array, and operate on that.