unable to get the vlookup property of the worksheetfunction class

L

Legacy 93538

Guest
Hi

I have created this loop, which loops through a cell range and for cell it takes the value of the cell and uses it to place a vlookup in the cell in the columns 6, 10, 21, 22, 23.

However when i run the code it produces an error saying "unable to get the vlookup property of the worksheetfunction class"

Code:
Nrow = 2If bImport = vbYes Then 'if the user selected yes to the question at the start
    'Opens perious version doc entered and copy data into temp sheet and closes it
    Application.StatusBar = "Importing previous version data"
    Set PPOld = Workbooks.Open(StrFldr & "\" & "HDE_PPIII_MONTH_Input_Reference_Form_V" & bVImport & ".xlsx")
    PPNew.Sheets.Add.Name = "ConvertManual"
    PPOld.Sheets("InputRefapd").cells.Copy Destination:=PPNew.Sheets("ConvertManual").Range("A1")
    PPOld.Close
    'Loops through column in
    For Each cell In PPNewIR.Range("A2:A3000")
        If cell.Value <> "" Then
           PPNewIR.cells(Nrow, 6).Value = Application.WorksheetFunction.VLookup(cell.Value, PPNew.Sheets("ConvertManual").Range("A2:Y3000"), 10, False)
           PPNewIR.cells(Nrow, 10).Value = Application.WorksheetFunction.VLookup(cell.Value, PPNew.Sheets("ConvertManual").Range("A2:Y3000"), 10, False)
           PPNewIR.cells(Nrow, 21).Value = Application.WorksheetFunction.VLookup(cell.Value, PPNew.Sheets("ConvertManual").Range("A2:Y3000"), 21, False)
           PPNewIR.cells(Nrow, 22).Value = Application.WorksheetFunction.VLookup(cell.Value, PPNew.Sheets("ConvertManual").Range("A2:Y3000"), 22, False)
           PPNewIR.cells(Nrow, 23).Value = Application.WorksheetFunction.VLookup(cell.Value, PPNew.Sheets("ConvertManual").Range("A2:Y3000"), 23, False)
        End If
        Application.StatusBar = cell.Address
    Next cell
Application.StatusBar = "Formatting and deleteing temporary Sheet"
PPNewIR.Select: PPNewIR.cells.Copy: PPNewIR.PasteSpecial Paste:=xlPasteValues
PPNew.Sheets("ConvertManual").Delete
End If

Does anyone know why its doing this and how to solve it? as i have never come across this error before.

Thanks

Jessicaseymour
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
It's happening because one of your vlookup's is unsuccessful, can't find what you are looking for...
 
Upvote 0
Hi

Thanks for replying!

Its erroring on the first vlookup statement, when writing it i was unsure of the syntax of the vlookup is it right?

Code:
 VLookup(cell.Value, PPNew.Sheets("ConvertManual").Range("A2:Y3000"), 10, False)
 
Upvote 0
Syntax is never my strong suit, but I think you can use cell, instead of cell.value. I think it is also Application.vlookup and not application.worksheetfunction.vlookup
 
Upvote 0
Hi

Ok i tried application.vlookup and i got a syntax error of "Expected list seperator or )"
 
Upvote 0
Odd. The syntax looks fine to me (and the code isn't highlighted in red in the VBE).
 
Upvote 0
Hi

I have been looking at it and i have altered the code and its no longer in a loop and it works now except when it puts the vlookup in the cell i get #N/A instead of a value.

Code:
Range("F2").Value = "=If(A1 = 0, 0, VLookup(A1, ConvertManual!A2:Y3000, 6, False))"

I have checked a value in cell A1 is in the range i am asking it to look in.
 
Upvote 0
Hi

The range its looking at has both text and numbers.

Would it matter if the column the value it is looking up in is after the column its trying to return data from?
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,460
Members
448,965
Latest member
grijken

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