ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vlookup in VBA (https://www.excelbanter.com/excel-programming/318042-vlookup-vba.html)

Teresa

vlookup in VBA
 
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


Frank Kabel

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

--
Regards
Frank Kabel
Frankfurt, Germany

"teresa" schrieb im Newsbeitrag
...
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

vlookup in VBA
 
Thanks Frank - very helpful

"Frank Kabel" wrote:

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

--
Regards
Frank Kabel
Frankfurt, Germany

"teresa" schrieb im Newsbeitrag
...
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




stanshoe

vlookup in VBA
 
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


"teresa" wrote:

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



All times are GMT +1. The time now is 12:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com