VBA - Faster alternative to Vlookup?

danmcdon

New Member
Joined
Mar 4, 2010
Messages
2
I have a macro that loops thousands of times, and I believe it is really being slowed down by several Vlookups occuring in the code. I have several large arrays with data, and I need to pull data from the array in each loop using a different lookup value. Currently I am using worksheetfunction.vlookup, but if you suggest a faster way I will be eternally grateful!

i.e.

Dim ArrData as Variant

ArrData = range("data") 'range is approx 10,000 x 5

Result = Application.WorksheetFunction.VLookup(LookupValue, Range("Data"), 5, -1)
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hello

How many times do you execute that VLOOKUP function within your code?
Because 10,000 is not excessively high, and also you do not search for an exact match - which is way faster.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top