Vlookup via VBA

Bob

New Member
Joined
Feb 20, 2002
Messages
1
This is SLOW, any suggestions?

For Lookin = 2 To LR
LookRange = Sheets("Query").Range("E" & Lookin)
InRange = Sheets("Character Values").Range("A:B")
Answer1 = Application.WorksheetFunction.VLookup(Sheets("Query").Range("E" & Lookin), Sheets("Character Values").Range("A:B"), 2, False)

Sheets("Query").Range("G" & Lookin).Value = Answer1
Next Lookin
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
This may speed it up a bit:

1) You use
LookRange = Sheets("Query").Range("E" & Lookin)
InRange = Sheets("Character Values").Range("A:B")

to define two variables that you never use in the definition of Answer1.
Try getting rid of them. At least move the definition of InRange outside the loop.

2) If you defined LookRange (before the loop) as
Set LookRange = Sheets("Query").Range(Cells(2,5),Cells(LR,5))

and

Set InRange = = Sheets("Character Values").Range("A:B")

then you could use:

For Lookin = 2 To LR
Answer1 = Application.WorksheetFunction.VLookup(LookRange.Cells(Lookin-1),InRange,2,False)
Sheets("Query").Range("G" & Lookin).Value = Answer1
Next Lookin

HTH!
 
Upvote 0

Forum statistics

Threads
1,214,424
Messages
6,119,407
Members
448,894
Latest member
spenstar

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