G
Guest
Hi Everyone,
Using VBA I need to loop through a lot of records, pick up an account name,
find the account name in a big table and return the account balance.
In terms of speed which is quicker, option 1 or 2:
Option 1 : Vlookup
myBalance = Application.WorksheetFunction.VLookup(myAccount, myBigTable,
iBalanceColumn, False)
Option 2 : Loop through the big table
dim r as range
For Each r in myBigTable
If r.Cells(1, iAccountColumn) = myAccount then
myBalance = r.Cells(1, iBalanceColumn)
Exit For
End if
Next
I had heard that using WorksheetFunctions in VBA was quite slow. What do you
think? Or is there an alternative even quicker way to do this???
TIA
big t
Using VBA I need to loop through a lot of records, pick up an account name,
find the account name in a big table and return the account balance.
In terms of speed which is quicker, option 1 or 2:
Option 1 : Vlookup
myBalance = Application.WorksheetFunction.VLookup(myAccount, myBigTable,
iBalanceColumn, False)
Option 2 : Loop through the big table
dim r as range
For Each r in myBigTable
If r.Cells(1, iAccountColumn) = myAccount then
myBalance = r.Cells(1, iBalanceColumn)
Exit For
End if
Next
I had heard that using WorksheetFunctions in VBA was quite slow. What do you
think? Or is there an alternative even quicker way to do this???
TIA
big t