Vlookup problem using vba

Alpacino

Well-known Member
Joined
Mar 16, 2011
Messages
511
I have a 2 columns in columns AB for names and AC for figures these go down to rows 34. I have another list in column A with the same list of names in a different order I want to use a vlookup formula to match the figures from AC To the names in column A and put the figures in column B

I have tried this:
Dim i As Double
For i = 2 to 34
Cells(I, 2).Value = Application.WorksheetFunction.Vlookup(cells(i, 1).Value,Range("AB2:AC34"),2,0)

Next i

But it has error on worksheet function
Anyone help
Thanks
Alan
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
it should be .formulaR1C1 and not .value, it is better you name the range

try the below, try the below it is for variable range

Code:
For i = 2 To finalrow
        On Error Resume Next
            Cells(i, 2).FormulaR1C1 = Application.WorksheetFunction.VLookup(Cells(i, 1), Range("lookuptable"), 3, False)
            On Error GoTo 0
        Next i
 
Upvote 0

Forum statistics

Threads
1,224,567
Messages
6,179,571
Members
452,927
Latest member
whitfieldcraig

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