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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to get Vlookup Property of WorksheetFunction class error

Status
Not open for further replies.

cfcanter

Technical User
Sep 12, 2001
31
US
I am getting an error message "Unable to get Vlookup Property of WorksheetFunction class". Below is the code I am trying to use. I have just about every reference added that I can think of. Does anyone have an idea of what I am doing wrong? Please help, I'm desperate to turn a 3 day task into a 1/2 hour task.

thanks
c2

Global x, y, iComponentRow, iThiscolumn As Integer
Global dDemand As Double
Global sPartAddress As String
Global strStartMatl As String
Global aryComponent(10) As String

Sub GO()
Call FindPart
Call LoadArry
Call locateComponent
End Sub



Sub FindPart()
'
sFindCell = ActiveCell.Value
sPartAddress = ActiveCell.Address
Sheets("BKLOGTHRUDEC31050702 (3)").Select
Columns("A:A").Select
Range("A17").Activate
Selection.Find(What:=sFindCell, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
End Sub

Sub LoadArry()

x = 1
ActiveCell.Offset(0, 4).Select
Do Until ActiveCell.Value = ""
aryComponent(x) = ActiveCell.Value
x = x + 1
ActiveCell.Offset(0, 1).Select
Loop
Sheets("mrp").Select
Range(sPartAddress).Select
End Sub

Sub locateComponent()
dDemand = ActiveCell.Offset(0, 1).Value
ActiveCell.Offset(0, 3).Select
iThisRow = ActiveCell.Row
iThiscolumn = ActiveCell.Column
iComponentRow = -1 * (ActiveRow - 4)
For y = 1 To x
Do Until Cells(iComponentRow, iThiscolumn).Value = "END"

If Cells(iComponentRow, iThiscolumn).Value = aryComponent(y) Then

End If
iThiscolumn = ActiveCell.Column + 1
ActiveCell.Offset(0, 1).Select
Loop
Range(sPartAddress).Select
ActiveCell.Offset(0, 3).Select
iThiscolumn = ActiveCell.Column
Next y
End Sub

Sub Formula1()
Dim dTestValue As Double

' error is on this line
iComponentValue = Application.WorksheetFunction _
.VLookup(aryComponent(y), "'wafer inv'A:S", 19, False)

dTestValue = ActiveCell.Value
If dTestValue >= dDemand Then
ActiveCell.Value = dDemand
Else
If dTestValue < dDemand And dTestValue > 0 Then
ActiveCell.Value = dTestValue
Else
ActiveCell.Value = &quot;xxx&quot;
End If
End If


End Sub Craig Canter
Cost Accountant
Sipex
Milpitas, CA
 
dear cf,

first of all, Do you have set

option explicit

on the very start of your program??
if not do so.

next question what value is y when the error occurs??


I assume their is a problem with the scope of your variables and in consequence with the value of 'y'

HTH
regards astrid

 
dear craig,

first of all, Do you have set

option explicit

on the very start of your program??
if not do so.

next question what value is y when the error occurs??


I assume their is a problem with the scope of your variables and in consequence with the value of 'y'

HTH
regards astrid

 
Hi,

I had a similar problem and rmikesmith told me to remove the worksheetfunction word, so it would end up looking like


Code:
iComponentValue = Application.VLookup(aryComponent(y), &quot;'wafer inv'A:S&quot;, 19, False)

It worked for me on thread 707-269117

Regards,

alan
 
The other way round should work as well. Some of the functions don't like the doublecall application.worksheetfunction.

Use either application.vlookup or worksheetfunction.vlookup

HTH
Geoff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top