farmerscott
Well-known Member
- Joined
- Jan 26, 2013
- Messages
- 824
- Office Version
- 365
- Platform
- Windows
Hi Everybody,
I have the following code that does a vlookup two ways. The first puts the formula into the worksheet and it then calculates it and the 2nd way VBA calculates it and then puts it into the worksheet (...or thats the way I understand it).
The first way of doing it is rather quick (covering 142K of rows) while the 2nd is very slow.
I would appreciate some suggestions to speed up the 2nd way.
Appreciate the help.
FarmerScott
I have the following code that does a vlookup two ways. The first puts the formula into the worksheet and it then calculates it and the 2nd way VBA calculates it and then puts it into the worksheet (...or thats the way I understand it).
The first way of doing it is rather quick (covering 142K of rows) while the 2nd is very slow.
I would appreciate some suggestions to speed up the 2nd way.
Code:
Sub Get_and_organise_data()
Dim x As Long
lr = Worksheets("Sheet1").Cells(Rows.Count, "F").End(xlUp).Row
'1st way....
Range("G1:G" & lr).FormulaR1C1 = "=VLOOKUP(RC[-1],R1C1:R1762C2,2,False)"
'2nd way.......
For x = 1 To lr
On Error Resume Next
Value = Cells(x, 6).Value
Rng = Range("A1:C1762")
Answer = Application.WorksheetFunction.VLookup(Value, Rng, 3, False)
Cells(x, 8).Value = Answer
Next x
End Sub
Appreciate the help.
FarmerScott