Could someone please look at this VLookup...

London_Calling

Active Member
Joined
Feb 27, 2007
Messages
256
.. before I go slightly mental and sit in the corner rocking backwards and forwards:

Code:
Dim PR As Range
Set PR = Workbooks("codeBookNew.xlsm").Worksheets("Sheet1").Range("B2:C35")
finalArr1(x, 3) = Application.WorksheetFunction.VLookup(Cells(i, 6), PR, 2, False)

It's generating 'Unable to get the Vlookup property of the WorksheetFunction Class'. I just can't see the error.....

Most grateful if someone can. Cheers.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
That means that it isn't finding a match. This should suppress the error message but you'll still get an error value returned

Code:
Dim PR As Range
Set PR = Workbooks("codeBookNew.xlsm").Worksheets("Sheet1").Range("B2:C35")
finalArr1(x, 3) = Application.VLookup(Cells(i, 6), PR, 2, False)
 
Upvote 0
jonmo1 - I did (eventually) check the Dim statements because I've made that error before. But Peter is quite right, it's not finding a match.

Thanks for your interest!
 
Upvote 0
To prevent from debugging upon #N/A errors, And eliminate #N/A errors from appearing in the array...

1. drop the worksheetfunction
2. assign the result of the Vlookup to a variable.
3. if the variable is not an error, assign the variable to the array.

Try like

Code:
Set PR = ThisWorkbook.Worksheets("Sheet1").Range("B2:C35")
MyVariable = Application.VLookup(Cells(i, 6), PR, 2, False)
If Not IsError(MyVariable) Then
    finalArr1(x, 3) = MyVariable
End If
 
Upvote 0
Maybe like this or jonmo's suggestion

Code:
Dim PR As Range
Set PR = Workbooks("codeBookNew.xlsm").Worksheets("Sheet1").Range("B2:C35")
If Not IsError(Application.VLookup(Cells(i, 6), PR, 2, False)) Then finalArr1(x, 3) = Application.VLookup(Cells(i, 6), PR, 2, False)
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,877
Members
452,949
Latest member
Dupuhini

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