Using an Array instead of a Vlookup to improve speed
That would probably a lot slower.
VLOOKUP is slow when the 4th argument is set to FALSE.
Use a sorted range and set the argument tot TRUE (default); this requires
that you check to see if the item found is the correct one. Because you now
probably need 2 (or even more) VLOOKUPS, you could use MATCH instead, and
use INDEX to retrieve the items from the table.
--
Kind regards,
Niek Otten
Microsoft MVP - Excel
"Frank & Pam Hayes" wrote in message
news:KBlKe.9141$0d.3629@trnddc02...
I have an two dimensional array (MyArray) that describes 5000 invoices.
MyArray(i, 1) is the PRODUCT
MyArray(i, 2) is the VOLUME
MyArray(i, 3) is the REVENUE
MyArray(i, 4) is the TYPE
I am using Application.Vlookup to lookup the PRODUCT in a named range on a
worksheet to see if this is a product I sold in the previous period. If
the Vlookup is successful, I put "Existing Product" in MyArray(i, 4). If
the vlookup returns an error (using FALSE as the last argument), then I
put "New Product" in MyArray(i, 4).
The Application.Vlookup is a bit slow. Can someone point me to a VBA
example where the author wrote the target range into a second Array and
then used a For Next loop to perform the same basic logic as the vlookup
would?
Thanks,
Frank Hayes
|