Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 2003 Vlookup problem

Status
Not open for further replies.

JA3395

Programmer
May 22, 2007
88
IE
HELP!!

Code:
Const cMATNR = 1

'Set myRange = .Range(.Cells(cDataStartRow, cDataStartCol), Cells(GetLastRow(ws), GetLastCol(ws)))
Set myRange = .Range("A2:AD1541")
    
' locate MATNR in range
varValue = Application.WorksheetFunction.VLookup(MATNR, myRange, cMATNR, False)

I get the error

Unable to get the Vlookup property of the WorksheetFunction Class

I'm having real problems finding sensible/helpful documentation on WorksheetFunction syntax. Any pointers to better Reference documentation than msdn2 would be a BIG help!

J.
 
google is your friend...


the first result turns up that the error you are getting is the same as the N/A# you get in a cell.

trap or ignore the error:

Code:
On Error Resume Next
varValue = Application.WorksheetFunction.VLookup(MATNR, myRange, cMATNR, False)
If Err = 0 Then
 ' value found
Else
 ' not found
End If


mr s. <;)
 
you don't need to use:
Application.WorksheetFunction

generally just use either one or the other

Application.vlookup
or
Worksheetfunction.vlookup

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
What is MATNR ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

MATNR just contains a number in string format, just a variable, don't worry about it.

J.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top