Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to reference unsaved workbook in functions????

Hi Folks:

I have been scratching my head over this problem for some time.

perhaps someone out there can help:

I want to use VLOOKUP in the following way:

the look up value is in 1st column of one spreadsheet and the table_array
is range A:B of another spreadsheet which is unsaved. How do I reference
the table array when I dont know the name of the workbook?

I know that the unsaved workbook is the last one opened so ive tried

set myworkbook=workbooks(wokrbooks.count)

then in my VLOOKUP formula
=VLOOKUP(A:A,[myworkbook]CA!$A:$B,2)

but that doesnt work

ive also tried

Set myrange = myworkbook.Worksheets("mysheet").Range("$A:$B")


=VLOOKUP(A:A,myrange,2)


and that does not work either

any help would be really appreciated


thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default How to reference unsaved workbook in functions????



set myworkbook=workbooks(wokrbooks.count)


Does this give you the right workbook? Is it the last workbook opened by
the user, or opened by your code?

then in my VLOOKUP formula
=VLOOKUP(A:A,[myworkbook]CA!$A:$B,2)


Are you setting this formula in code? If so, the formula is a string and
you can build that string. If the formula looks like this

=VLOOKUP(A:A,[MyBook.xls]CA!$A:$B,2)

then your VBA would look like

Range("a1").Formula = "=VLOOKUP(A:A,[" & myworkbook.Name & "]CA!$A:$B,2)"


--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.


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
Shared Workbook User had unsaved information disappear Aeryn635 Excel Worksheet Functions 1 January 15th 10 05:31 AM
Need reference for max and [#this row] functions SCC Excel Worksheet Functions 1 September 4th 09 05:54 PM
How to recover unsaved workbook? P8ja Excel Discussion (Misc queries) 1 November 28th 05 12:44 PM
Need to reference existing functions in a custom function: possibl dofnup Excel Worksheet Functions 5 August 6th 05 11:42 AM
Closing an Unsaved (but Changed) Workbook Mike[_64_] Excel Programming 4 December 31st 03 01:07 AM


All times are GMT +1. The time now is 04:54 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"