Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default referencing a name from another book

hi all

how do i reference a named range from another book?

just a generic example would be sufficient
ie if my named range is

'MyNamedRange' and it is defined in the workbook 'Book2.xls' on worksheet
MySheetName in path c:\temp

how do i reference MyNamedRange in 'Book3.xls'



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default referencing a name from another book

Dim bk as Workbook
Dim rng as Range
Dim bNotOpen as Boolean
on Error Resume Next
set bk = Workbooks("Book2.xls")
On Error goto 0
if bk is nothing then
set bk = Workbooks.Open("C:\temp\book2.xls")
bNotOpen = True
End if
set rng = bk.Names("MyNamedRange").RefersToRange
v = rng.Value
if bNotOpen then
bk.Close SaveChanges:=False
set rng = nothing
set bk = nothing
End if


--
Regards,
Tom Ogilvy


"Gixxer_J_97" wrote in message
...
hi all

how do i reference a named range from another book?

just a generic example would be sufficient
ie if my named range is

'MyNamedRange' and it is defined in the workbook 'Book2.xls' on worksheet
MySheetName in path c:\temp

how do i reference MyNamedRange in 'Book3.xls'





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default referencing a name from another book

thanks Tom! that's perfect, however i should have specified...
i need this in a cell formula version

the formula i am using is a sumproduct formula which looks like

=sumproduct((MyNamedRange1="A")*(MyNamedRange2))
(as an array formula)

i am copying this sheet to another workbook and need to reference it from
the new workbook

ie if i am referencing a cell from another workbook i do
=[Book2.xls]MySheet!$E$44

i need to do the same thing, but reference the Named Range instead

that a bit clearer?


thanksi!

J
"Tom Ogilvy" wrote:

Dim bk as Workbook
Dim rng as Range
Dim bNotOpen as Boolean
on Error Resume Next
set bk = Workbooks("Book2.xls")
On Error goto 0
if bk is nothing then
set bk = Workbooks.Open("C:\temp\book2.xls")
bNotOpen = True
End if
set rng = bk.Names("MyNamedRange").RefersToRange
v = rng.Value
if bNotOpen then
bk.Close SaveChanges:=False
set rng = nothing
set bk = nothing
End if


--
Regards,
Tom Ogilvy


"Gixxer_J_97" wrote in message
...
hi all

how do i reference a named range from another book?

just a generic example would be sufficient
ie if my named range is

'MyNamedRange' and it is defined in the workbook 'Book2.xls' on worksheet
MySheetName in path c:\temp

how do i reference MyNamedRange in 'Book3.xls'






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default referencing a name from another book

Thanks Tom!

last question - does your method work if the named range is created
dynamically?
ie =offset(......)?

"Tom Ogilvy" wrote:

The easiest way is to open book2. Then build your formula in the formula
bar by putting in

=SumProduct((
then navigate to book2 and click on the cell(s) that make up MyNamedRange

when Excel updates the formula it will use the named range in the formula
and you will have the syntax.

--
Regards,
Tom Ogilvy


"Gixxer_J_97" wrote in message
...
thanks Tom! that's perfect, however i should have specified...
i need this in a cell formula version

the formula i am using is a sumproduct formula which looks like

=sumproduct((MyNamedRange1="A")*(MyNamedRange2))
(as an array formula)

i am copying this sheet to another workbook and need to reference it from
the new workbook

ie if i am referencing a cell from another workbook i do
=[Book2.xls]MySheet!$E$44

i need to do the same thing, but reference the Named Range instead

that a bit clearer?


thanksi!

J
"Tom Ogilvy" wrote:

Dim bk as Workbook
Dim rng as Range
Dim bNotOpen as Boolean
on Error Resume Next
set bk = Workbooks("Book2.xls")
On Error goto 0
if bk is nothing then
set bk = Workbooks.Open("C:\temp\book2.xls")
bNotOpen = True
End if
set rng = bk.Names("MyNamedRange").RefersToRange
v = rng.Value
if bNotOpen then
bk.Close SaveChanges:=False
set rng = nothing
set bk = nothing
End if


--
Regards,
Tom Ogilvy


"Gixxer_J_97" wrote in message
...
hi all

how do i reference a named range from another book?

just a generic example would be sufficient
ie if my named range is

'MyNamedRange' and it is defined in the workbook 'Book2.xls' on

worksheet
MySheetName in path c:\temp

how do i reference MyNamedRange in 'Book3.xls'









  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default referencing a name from another book

I don't know, but if it doesn't, create a named range in your Book2 that
isn't dynamic and do it. That will give you the syntax, then edit it use
your dynamic range.

If you intend to have book2 closed after creating the link, I am not sure if
that works or not. You can tell us.

--
Regards,
Tom Ogilvy

"Gixxer_J_97" wrote in message
...
Thanks Tom!

last question - does your method work if the named range is created
dynamically?
ie =offset(......)?

"Tom Ogilvy" wrote:

The easiest way is to open book2. Then build your formula in the

formula
bar by putting in

=SumProduct((
then navigate to book2 and click on the cell(s) that make up

MyNamedRange

when Excel updates the formula it will use the named range in the

formula
and you will have the syntax.

--
Regards,
Tom Ogilvy


"Gixxer_J_97" wrote in message
...
thanks Tom! that's perfect, however i should have specified...
i need this in a cell formula version

the formula i am using is a sumproduct formula which looks like

=sumproduct((MyNamedRange1="A")*(MyNamedRange2))
(as an array formula)

i am copying this sheet to another workbook and need to reference it

from
the new workbook

ie if i am referencing a cell from another workbook i do
=[Book2.xls]MySheet!$E$44

i need to do the same thing, but reference the Named Range instead

that a bit clearer?


thanksi!

J
"Tom Ogilvy" wrote:

Dim bk as Workbook
Dim rng as Range
Dim bNotOpen as Boolean
on Error Resume Next
set bk = Workbooks("Book2.xls")
On Error goto 0
if bk is nothing then
set bk = Workbooks.Open("C:\temp\book2.xls")
bNotOpen = True
End if
set rng = bk.Names("MyNamedRange").RefersToRange
v = rng.Value
if bNotOpen then
bk.Close SaveChanges:=False
set rng = nothing
set bk = nothing
End if


--
Regards,
Tom Ogilvy


"Gixxer_J_97" wrote in message
...
hi all

how do i reference a named range from another book?

just a generic example would be sufficient
ie if my named range is

'MyNamedRange' and it is defined in the workbook 'Book2.xls' on

worksheet
MySheetName in path c:\temp

how do i reference MyNamedRange in 'Book3.xls'













  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default referencing a name from another book

this worked when the originating book (MyBook.xls) was open:

'c:\temp\MyBook.xls'!MyNamedRange
when you close MyBook, there is a #REF! error
(just leaving the MyNamedRange w/o the path produces a #VALUE! error)

anyone have an idea on how to get this to work when the original book is
closed?

i'm thinking this will work if the named range is static, but i need to use
dynamic ranges


"Tom Ogilvy" wrote:

I don't know, but if it doesn't, create a named range in your Book2 that
isn't dynamic and do it. That will give you the syntax, then edit it use
your dynamic range.

If you intend to have book2 closed after creating the link, I am not sure if
that works or not. You can tell us.

--
Regards,
Tom Ogilvy

"Gixxer_J_97" wrote in message
...
Thanks Tom!

last question - does your method work if the named range is created
dynamically?
ie =offset(......)?

"Tom Ogilvy" wrote:

The easiest way is to open book2. Then build your formula in the

formula
bar by putting in

=SumProduct((
then navigate to book2 and click on the cell(s) that make up

MyNamedRange

when Excel updates the formula it will use the named range in the

formula
and you will have the syntax.

--
Regards,
Tom Ogilvy


"Gixxer_J_97" wrote in message
...
thanks Tom! that's perfect, however i should have specified...
i need this in a cell formula version

the formula i am using is a sumproduct formula which looks like

=sumproduct((MyNamedRange1="A")*(MyNamedRange2))
(as an array formula)

i am copying this sheet to another workbook and need to reference it

from
the new workbook

ie if i am referencing a cell from another workbook i do
=[Book2.xls]MySheet!$E$44

i need to do the same thing, but reference the Named Range instead

that a bit clearer?


thanksi!

J
"Tom Ogilvy" wrote:

Dim bk as Workbook
Dim rng as Range
Dim bNotOpen as Boolean
on Error Resume Next
set bk = Workbooks("Book2.xls")
On Error goto 0
if bk is nothing then
set bk = Workbooks.Open("C:\temp\book2.xls")
bNotOpen = True
End if
set rng = bk.Names("MyNamedRange").RefersToRange
v = rng.Value
if bNotOpen then
bk.Close SaveChanges:=False
set rng = nothing
set bk = nothing
End if


--
Regards,
Tom Ogilvy


"Gixxer_J_97" wrote in message
...
hi all

how do i reference a named range from another book?

just a generic example would be sufficient
ie if my named range is

'MyNamedRange' and it is defined in the workbook 'Book2.xls' on
worksheet
MySheetName in path c:\temp

how do i reference MyNamedRange in 'Book3.xls'












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
Moving worksheets to another book - 2nd book will not appear jb0100 Excel Discussion (Misc queries) 2 March 18th 09 03:09 PM
copy worksheets to new book without linking to original book Lori Excel Discussion (Misc queries) 2 March 4th 09 04:46 PM
to disconnect a destination book from a source book officegirl Excel Discussion (Misc queries) 4 December 10th 07 09:28 PM
Open book, check for macros, close book Robin Hammond[_2_] Excel Programming 5 March 31st 05 06:09 PM
referencing other work book using the INDIRECT function jC! Excel Programming 2 December 2nd 03 08:14 AM


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