LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default external range in VBA (user defined formula)

I don't know if this will work for your particular situation, but there is a
method documented at John Walkenbach's site:
A VBA Function to Get a Value From a Closed File
http://j-walk.com/ss/excel/tips/tip82.htm

In your first post you were using defined names, in this post, absolute
ranges. You may have to play around to get what you want. For example for
defined ranges the following returns the value in 'rng' for a closed
workbook:

MsgBox ?ExecuteExcel4Macro("'D:\Data\[Book1.xls]Sheet1'!rng")

where 'rng' is a single-cell defined name. I don't know yet if there is a
way to get the top-leftmost cell in a multi-cell defined range.

Tim


"Gord D" wrote in message
...
Thanks for your suggestions guys. I gave them a shot, both with the
other sheet opened, and closed. (Ultimately, it has to work with the
other sheet closed)

I figured that if the workbook is closed, I'd have to get at it via the
full path (otherwise how would excel know where to look?)

At first glance, it doesn't look like you can get at ranges of closed
workbooks.

As you can see, I tried putting the full path, sheet, and range all
inside range(), and also tried specifying them in
Workbooks().worksheets().range()




'// doesn't work: Method 'Range' of Object '_Global'
failed

MsgBox " contents of cell in external range: " &
Range("\\hqserver01\rfp_accounti\TABLES\2003\[SCDCM.xls]SC_EL2_CM!A1:P60
00").Cells(1, 3).Value


'// works when SCDCM.xls is open, otherwise same as above
MsgBox " contents of cell in external range: " &
Range("[SCDCM.xls]SC_EL2_CM!A1:P6000").Cells(1, 3).Value




'// doesn't work: Subscript out of range

MsgBox " contents of cell in external range: " &
Workbooks("\\hqserver01\rfp_accounti\TABLES\2003\S CDCM.xls").Worksheets(
"SC_EL2_CM").Range("A1:P6000").Cells(1, 1).Value


'// works when SCDCM.xls is open, otherwise same as above
MsgBox " contents of cell in external range: " &
Workbooks("SCDCM.xls").Worksheets("SC_EL2_CM").Ran ge("A1:P6000").Cells(1
, 1).Value



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



 
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
help text for user defined formula WJvR Excel Worksheet Functions 2 July 23rd 08 04:34 PM
User-defined range for graph royend Excel Discussion (Misc queries) 3 September 4th 07 09:11 AM
Passing a range to a user defined function Gary Nelson Excel Discussion (Misc queries) 1 July 19th 07 04:22 PM
"User-defined type not defined" message in Excel RW1946 Excel Discussion (Misc queries) 0 August 31st 05 12:14 PM
external range in VBA (user defined formula) Tim Zych[_2_] Excel Programming 0 July 22nd 03 02:02 AM


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