Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default vlookup table in another workbook

convert your date to a long in the vlookup. This usually works better:

Sub VLU()
Dim Taarich As Date ' Taarich is Date in Hebrew
Dim LUResults As Variant
Dim LupTable As Range
Set LupTable = Workbooks("book2.xls").Sheets("sheet1").Range("Tab le01")
Taarich = ActiveCell.Offset(0, -1).Value
LUResults = Application.VLookup(clng(Taarich), LupTable, 3, True)
if iserror(LUResults) then
msgbox Taarich & " was not found"
else
MsgBox LUResults
end if
End Sub

--
Regards,
Tom Ogilvy


"Rachel" wrote in message
...
Hi everybody, thanks for trying to help
What I may not put clear is, that for testing my vba procedure
I chose a date that is in the table01 col A
and still get an error no 2042
while writing the function interactively
=VLOOKUP(A5,Book2.xls!Table01,3,FALSE)
I get the expected results
Any Idea?
Thanks rachel

"Dave Peterson" wrote:

I find using variables make it a bit simpler to debug.

dim LookUpTable as range
dim LookUpCell as Range
dim res as variant

set lookupTable =

workbooks("book2.xls").worksheets("sheet1").range( "table01")
set lookupCell = workbooks("book1.xls").worksheets("sheet1").range( "a1")

res = application.vlookup(lookupcell.value, lookuprng, 2)
'or for an exact match:
res = application.vlookup(lookupcell.value, lookuprng, 2, false)

if iserror(res) then
'error was returned, what happens?
else
msgbox res
end if

===
And by using application.vlookup() instead of
application.worksheetfunction.vlookup(), I can test the result to see if

it
returned an error.

And I think it's always a good idea to include the extension of the file
(assuming that book1 and book2 have both been saved).




Rachel wrote:

I want to get the vlookup results to a variable, where that table data

is in
book2
and the key search is in book1 somthing like
Vlook = application.worksheet.vlookup(book1!sheet1[a1],
book2!sheet1[table01], 2)
this does not work. Both worbooks are in the same directory, and I use

excel
2000
and windoew xp
thanks rachel


--

Dave Peterson



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
Refresh pivot table in workbook A when changing a cell in workbook gildengorin Excel Worksheet Functions 2 March 17th 09 04:59 PM
vlookup other workbook swell estimator[_2_] Excel Discussion (Misc queries) 1 September 9th 08 07:10 PM
How to copy pivot table workbook to new workbook? Wendy New Users to Excel 0 May 8th 06 11:57 PM
Open Workbook - Select Range as table for vlookup Alan Excel Discussion (Misc queries) 4 November 3rd 05 06:56 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 01:36 PM.

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"