Vlookup VBA on dates

G

gianni gianni

Hello,

I'm writing a piece of VBA code and I need to run a vlookup.

In particular, I've written the following code

fir = Application.WorksheetFunction.VLookup(period, Range("curve"), 2)

where:

- fir is a number;
- period: is a date written by a named range;
- curve: is a named range with dates on the 1st column and numbers in
the other columns.

I need to select a number (fir) for the nearest date to "period" in the
"curve" matrix.

When I run the model, it gets me the error:

Runtime error '1004' - "Unable to
get the Vlookup property of the WorksheetFunction class".

Why?

*** Sent via Developersdex http://www.developersdex.com ***
 
P

Pranav Vaidya

this error means Vlookup() failed.
to handle this error add an error handling routine such as

On error goto <lable>

also change the datatype of the variable 'fir' to variant
 
B

Bob Phillips

The question is, why did it fail?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Vlookup in VBA 4
another Vlookup question 3
Using vLookup function in VBA 4
VLOOKUP & ISNA 2
Vlookup on a VB Form 1
VLookup Function in VB 5
VBA Pivot Table Error 1
VLookup error 4

Top