vlookup in VBA

G

Guest

Hi All,
I'm trying the code below for a Vlookup and get
"Application-defined or Object-defined error",
I'd love to know why:

Sub fact()

Range("b50").Select
Range("b50").Value = WorksheetFunction.VLookup("a50", "c39:d40", 2, [false])

End Sub
 
F

Frank Kabel

Hi
try:
Range("b50").Value = WorksheetFunction.VLookup(range("a50"),
range("c39:d40"), 2, 0)
 
G

Guest

Thanks Frank - very helpful

Frank Kabel said:
Hi
try:
Range("b50").Value = WorksheetFunction.VLookup(range("a50"),
range("c39:d40"), 2, 0)

--
Regards
Frank Kabel
Frankfurt, Germany

teresa said:
Hi All,
I'm trying the code below for a Vlookup and get
"Application-defined or Object-defined error",
I'd love to know why:

Sub fact()

Range("b50").Select
Range("b50").Value = WorksheetFunction.VLookup("a50", "c39:d40", 2, [false])

End Sub
 
G

Guest

Teresa-

Don't overlook the power of the Macro Recorder. Whenever you have trouble
with worksheet functions in VBA, try recording the formula as you enter it in
a cell. The recorder will show you the correct syntax.

-Stan
 

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

Top