Using an Array instead of a Vlookup to improve speed
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
|