Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default VBA/VLOOKUP Error Message

Hi,

I'm trying to us the VLOOKUP function in a VBA program. Decided to try a
simple code so see how things work and I can't get it to work. I am working in
Sheet 1 of a workbook. Typed the following VBA code:

"Sub ZOO()
Dim INVEN As Double
Cells(1, 3) = VLookup (A1, INVEN, 2)
End Sub"

When I run it I get a compile error telling me that the Sub or Function is not
defined. I thought the VLOOKUP function would automatically be recogized by
the program. I admit I am a novice at this but I am slowly learning. Can
anyone tell me what I am doing wrong? BTW, I type VLOOKUP in all caps and the
program changes some letters to small.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default VBA/VLOOKUP Error Message


Hi JimFor,

Try:

Application.WorksheetFunction.Vlookup


---
Regards,
Norman



"JimFor" wrote in message
...
Hi,

I'm trying to us the VLOOKUP function in a VBA program. Decided to try a
simple code so see how things work and I can't get it to work. I am
working in
Sheet 1 of a workbook. Typed the following VBA code:

"Sub ZOO()
Dim INVEN As Double
Cells(1, 3) = VLookup (A1, INVEN, 2)
End Sub"

When I run it I get a compile error telling me that the Sub or Function is
not
defined. I thought the VLOOKUP function would automatically be recogized
by
the program. I admit I am a novice at this but I am slowly learning.
Can
anyone tell me what I am doing wrong? BTW, I type VLOOKUP in all caps
and the
program changes some letters to small.

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default VBA/VLOOKUP Error Message

Thanks. Where exactly do I place that in the formula? Before the Dim
statement? Before the Cells statement? Add it to a particular line?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default VBA/VLOOKUP Error Message

Cells(1, 3) = Application.WorksheetFunction.Vlookup (A1, INVEN, 2)

and you'll probably need to be more specific (VBA usually won't intrepret A1
or INVEN as easily as Excel does when used in a cell formula):

Cells(1, 3) = Application.WorksheetFunction.Vlookup (Range("A1").Value,
Range("INVEN"), 2)

or even even more specific....:

Cells(1, 3) = Application.WorksheetFunction.Vlookup
(Worksheets("Sheet1").Range("A1").Value,
Worksheets("Sheet2").Range("INVEN"), 2)

Hope this doesn't scare you off,

--
George Nicholson

Remove 'Junk' from return address.


"JimFor" wrote in message
...
Thanks. Where exactly do I place that in the formula? Before the Dim
statement? Before the Cells statement? Add it to a particular line?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default VBA/VLOOKUP Error Message

Thanks much. Nope. I'm not scared. The more I do the more I understand and
the more II do the more I don't understand. But slowly the "understand": part
is growing larger.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vlookup Error Message - Excel 2003 Kim Excel Discussion (Misc queries) 9 August 24th 09 05:50 PM
error message during vlookup Deb Pingel Excel Discussion (Misc queries) 2 August 17th 06 03:39 PM
VLOOKUP error message Janeen Excel Discussion (Misc queries) 7 December 27th 05 08:55 PM
VLookup in VBA giving error message ayl322 Excel Discussion (Misc queries) 3 July 27th 05 06:06 PM
error message in Vlookup Jill[_7_] Excel Programming 11 August 17th 04 11:10 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"