Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Unresolved local named range

Newbie question.

Working in Excel 2000.
I have a workbook with a range called 'ABC'. I reference this range within a
VBA function as:
x = Application.Range("ABC")
This works well as long as it is the active workbook, when switching to
another workbook and forcing a calculation the range is not found. The way
to do this of course is to qualify it as:
x = Application.Range("'[Workbook.xls]Sheet1'!ABC")
Great, my problem is that I am not doing it in VBA but via a COM interface
where I only have the range name, not the workbook, or the sheet name!

My question: Is it not possible when defining a Range to include the
Workbook qualification in some way? When I try to do this via the menu
system, Excel just 'loses' this extra information?

Any help appreciated!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Unresolved local named range

Hi
as the other workbook has to be open to access the defined name you may
cycle through all workbooks. Something like

dim wbk as workbook
dim oName as name
Dim rng as range
on error resume next
for each wbk in application.workbooks
set oname=wbk.names("ABC")
if not oname is nothing then
exit for
end if
next wbk

set rng = oname.referstorange
msgbox rng.value
end sub


"Andre Louw" wrote:

Newbie question.

Working in Excel 2000.
I have a workbook with a range called 'ABC'. I reference this range within a
VBA function as:
x = Application.Range("ABC")
This works well as long as it is the active workbook, when switching to
another workbook and forcing a calculation the range is not found. The way
to do this of course is to qualify it as:
x = Application.Range("'[Workbook.xls]Sheet1'!ABC")
Great, my problem is that I am not doing it in VBA but via a COM interface
where I only have the range name, not the workbook, or the sheet name!

My question: Is it not possible when defining a Range to include the
Workbook qualification in some way? When I try to do this via the menu
system, Excel just 'loses' this extra information?

Any help appreciated!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Unresolved local named range


even using COM, i assume you've opened it
so you know the wb name = thus you can set a variable.

ELSE you must rely on the workbook that's ACTIVE
(last opened)

ELSE you must know (or store) the workbook name :(


BUT you can dispense with the sheetname IF
the name object has the workbook as parent...

Range( "'" & strWBNAME & "'!abc")
(Note NO brackets)



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Andre Louw" wrote:

Newbie question.

Working in Excel 2000.
I have a workbook with a range called 'ABC'. I reference this range
within a VBA function as:
x = Application.Range("ABC")
This works well as long as it is the active workbook, when switching
to another workbook and forcing a calculation the range is not found.
The way to do this of course is to qualify it as:
x = Application.Range("'[Workbook.xls]Sheet1'!ABC")
Great, my problem is that I am not doing it in VBA but via a COM
interface where I only have the range name, not the workbook, or the
sheet name!

My question: Is it not possible when defining a Range to include the
Workbook qualification in some way? When I try to do this via the menu
system, Excel just 'loses' this extra information?

Any help appreciated!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Unresolved local named range

Hi,

If you have any more concerns on it, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

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
Autofilter problem unresolved Jamie R[_2_] Excel Discussion (Misc queries) 4 December 3rd 08 08:59 PM
Array as a "named range" - formula ok in cells, but error as "named range" tskogstrom Excel Discussion (Misc queries) 11 December 28th 06 04:44 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
Copy a range from a CSV file in a webpage to my local worksheet Jav Pa Excel Programming 4 August 25th 04 01:57 AM
Reference styles and local/non-local formulae - international problems. Alan Howells[_2_] Excel Programming 2 February 24th 04 09:52 AM


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