Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
ayl322
 
Posts: n/a
Default VLookup in VBA giving error message


Hi, I'm having trouble making the vlookup function work in VBA.
the values that are used are all dates, I don't know if that makes a
difference.


Worksheets("sheet1").range("a1").value = application.WorksheetFunction.
_
Vlookup(Range("c1"), range("a:a"), 2)

this gives me a run-time error '1004' Unable to get the vlookup
property of the Worksheet function class


so i tried this:
Worksheets("sheet1").range("a1").value =
application.Vlookup(Range("c1"), _
range("a:a"), 2)

but this gives me a #REF error.

What am I doing wrong?

Any help would be appreciated!


--
ayl322
------------------------------------------------------------------------
ayl322's Profile: http://www.excelforum.com/member.php...fo&userid=9846
View this thread: http://www.excelforum.com/showthread...hreadid=390609

  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

This works for me

Worksheets("sheet1").Range("a1").Value = Application.VLookup _
(Range("c1"), Range("a:b"), 2)


--

HTH

RP
(remove nothere from the email address if mailing direct)


"ayl322" wrote in
message ...

Hi, I'm having trouble making the vlookup function work in VBA.
the values that are used are all dates, I don't know if that makes a
difference.


Worksheets("sheet1").range("a1").value = application.WorksheetFunction.
_
Vlookup(Range("c1"), range("a:a"), 2)

this gives me a run-time error '1004' Unable to get the vlookup
property of the Worksheet function class


so i tried this:
Worksheets("sheet1").range("a1").value =
application.Vlookup(Range("c1"), _
range("a:a"), 2)

but this gives me a #REF error.

What am I doing wrong?

Any help would be appreciated!


--
ayl322
------------------------------------------------------------------------
ayl322's Profile:

http://www.excelforum.com/member.php...fo&userid=9846
View this thread: http://www.excelforum.com/showthread...hreadid=390609



  #3   Report Post  
George Nicholson
 
Posts: n/a
Default


Vlookup(Range("c1"), range("a:a"), 2)

You are telling Vlookup to return a value from the 2nd column of a 1 column
range. It simply can't do that.

Change a:a to a:b (or something with 2 columns) and see if you get better
results.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"ayl322" wrote in
message ...

Hi, I'm having trouble making the vlookup function work in VBA.
the values that are used are all dates, I don't know if that makes a
difference.


Worksheets("sheet1").range("a1").value = application.WorksheetFunction.
_
Vlookup(Range("c1"), range("a:a"), 2)

this gives me a run-time error '1004' Unable to get the vlookup
property of the Worksheet function class


so i tried this:
Worksheets("sheet1").range("a1").value =
application.Vlookup(Range("c1"), _
range("a:a"), 2)

but this gives me a #REF error.

What am I doing wrong?

Any help would be appreciated!


--
ayl322
------------------------------------------------------------------------
ayl322's Profile:
http://www.excelforum.com/member.php...fo&userid=9846
View this thread: http://www.excelforum.com/showthread...hreadid=390609



  #4   Report Post  
L. Howard Kittle
 
Posts: n/a
Default

Hi ayl322,

Perhaps you need to rewrite your code similar to this. In your code you are
trying to return a value to A1 and your table array is the same column, A.
Also, you are asking to return the value in the second column of the table
array and you only have one column.

Worksheets("sheet1").Range("A1").Value = _
Application.WorksheetFunction. _
VLookup(Range("F1"), Range("B1:C5"), 2, 0)

So here I want to return a value to A1, using the value in F1 as the lookup
value and the table array is B1:C5 and I want the second column using the 2
and an exact match using the 0.

HTH
Regards,
Howard

"ayl322" wrote in
message ...

Hi, I'm having trouble making the vlookup function work in VBA.
the values that are used are all dates, I don't know if that makes a
difference.


Worksheets("sheet1").range("a1").value = application.WorksheetFunction.
_
Vlookup(Range("c1"), range("a:a"), 2)

this gives me a run-time error '1004' Unable to get the vlookup
property of the Worksheet function class


so i tried this:
Worksheets("sheet1").range("a1").value =
application.Vlookup(Range("c1"), _
range("a:a"), 2)

but this gives me a #REF error.

What am I doing wrong?

Any help would be appreciated!


--
ayl322
------------------------------------------------------------------------
ayl322's Profile:
http://www.excelforum.com/member.php...fo&userid=9846
View this thread: http://www.excelforum.com/showthread...hreadid=390609



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
Using Vlookup with validation Brian Excel Worksheet Functions 4 May 4th 23 03:43 AM
Have Vlookup return a Value of 0 instead of #N/A Mr Mike Excel Worksheet Functions 4 May 25th 05 04:51 PM
VLOOKUP problem Wazooli Excel Discussion (Misc queries) 5 March 26th 05 01:52 PM
vlookup data hidden within worksheet Excel Worksheet Functions 0 January 26th 05 12:09 PM
Vlookup info being used without vlookup table attached? Excel Worksheet Functions 0 January 25th 05 10:43 AM


All times are GMT +1. The time now is 07:08 AM.

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

About Us

"It's about Microsoft Excel"