View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
DG DG is offline
external usenet poster
 
Posts: 46
Default VLookup Function in VB

I tried that and got the same error message.

That's when I put the Sheets("DataQuery").Select statement in thinking that
it didn't have the focus on any sheet. But still getting the same error.

DG

"Vergel Adriano" wrote in message
...
DG,

Try it like this:

TESTVAR = WorksheetFunction.VLookup("COBRA", Range("A1:D20"), 4)


--
Hope that helps.

Vergel Adriano


"DG" wrote:

Why does this not work:

Sub TEST()
Dim TESTVAR As Integer
Sheets("DataQuery").Select
TESTVAR = Application.WorksheetFunction.VLookup("COBRA", "A1:D20", 4)
End Sub

I get a Run-time error '1004'
Unable to get the VLookup property of the WorksheetFunction class

Data looks something like this:

Supplier Item Qty Cost
AEARO AEA 123 5 2.50
COBRA COB 123 8 4.50
etc...

DG