vlookup in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Hi
try:
Range("b50").Value = WorksheetFunction.VLookup(range("a50"),
range("c39:d40"), 2, 0)
 
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
 
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
 
Back
Top