Named Ranges

  • Thread starter Thread starter Epinn
  • Start date Start date
E

Epinn

Note: This is a continuation of a previous discussion which you don't really need.

Dave,

I did an experiment. I opened a brand new workbook. On Sheet1, I selected A1:A10 and defined it with a name "Range123." Then, on Sheet2, I did the same. As soon as I did that, "Range123" from Sheet1 no longer existed. So, I don't really understand how the user can have the same named ranges within one workbook? You know what, I even took out the reference to Sheet and tried to force in just the cell reference; but Excel won't let me. What am I missing here? Wonder if *two* workbooks are involved when we talk about "same name?"

Sounds like you were talking about VBA. I didn't pick this up.

Look forward to your comments.

Epinn
 
Add a named range to a sheet. Now make a copy of that sheet into the same
workbook (Hold down the Ctrl key and drag and drop the sheet or right click
the sheet and select move or copy and make a copy of the sheet). You will now
have two named ranges with the same name on two different sheets...
 
If you want to create a worksheet level name on "Sheet 999", you'd use a name
like:

'Sheet 999'!Range123

If you don't include the sheet name, then the name will be global (workbook
level).

Get Jan Karel Pieterse's (with Charles Williams and Matthew Henson) Name
Manager:

You can find it at:
NameManager.Zip from http://www.oaltd.co.uk/mvp

It'll make it much easier to experiment with names. (In fact, Jan Karel (et al)
included a way to "globalize" or "localize" names.
 
Epinn,

If you are in Sheet1 and do Insert | Name Define to see you list of
names, you will also see against Range123 the sheet reference. Now
select Sheet2 and repeat, and you will see Range123 with a sheet
reference of Sheet2. They need not be the same ranges on their
respective sheets. If you have two identical names (on different
sheets) then you have to prefix the name with the sheet name to ensure
that you get the correct one (it will default to current sheet if the
sheet name is missing). If you delete one of them then the remaining
one does not need its sheet reference when you refer to it.

Hope this helps.

Pete
 
Didn't see where this started?

I'm not sure this is what you're asking so if it's not just store it in your
memory bank......

You can create one named range that refers to the active sheet only instead
of creating the a named range for each different sheet:

Name: Rng
Refers to: !$A$1:$A$10

So, if you're on sheet1 and you enter this formula: =SUM(Rng), it'll refer
to sheet1. If you're on sheet10 and enter the same formula it'll refer to
sheet10.

Biff

Note: This is a continuation of a previous discussion which you don't
really need.

Dave,

I did an experiment. I opened a brand new workbook. On Sheet1, I selected
A1:A10 and defined it with a name "Range123." Then, on Sheet2, I did the
same. As soon as I did that, "Range123" from Sheet1 no longer existed. So,
I don't really understand how the user can have the same named ranges within
one workbook? You know what, I even took out the reference to Sheet and
tried to force in just the cell reference; but Excel won't let me. What am
I missing here? Wonder if *two* workbooks are involved when we talk about
"same name?"

Sounds like you were talking about VBA. I didn't pick this up.

Look forward to your comments.

Epinn
 
I've seen posts where this type of name will cause trouble (calculation problems
when VBA calculates, IIRC).

Maybe it would be better to use:

=indirect("a1:a10")
 
Do you mean when that type of name is used in the code itself? If so, then I
wouldn't "blame" the name I'd "blame" the coder.

Biff
 
And if I'd remember the details, you'd have a reason.

But it's one of those things that's in my brain as "don't do". The reason is
lost in google somewhere.
I see. Well, I don't know enough VBA to play around with it and see what's
doin'.

Biff
 
Thank you all for your response. What I want is very simple, nothing to do with VBA.

Basically, I was trying to have the *same name* for A1:A10 on two sheets (within the same workbook) respectively. Jim and Biff gave me the answer.

I don't think I can name A1:A10 on Sheet1 as "ABC" and then also name B1:B10 on Sheet2 as "ABC" as well. I used insert>name>define and I also use the Sheet# to qualify the range, but no luck.

Can someone confirm this is not possible please?

The Name Manager may come in handy one of these days. Thanks Dave.

Epinn

Note: This is a continuation of a previous discussion which you don't really need.

Dave,

I did an experiment. I opened a brand new workbook. On Sheet1, I selected A1:A10 and defined it with a name "Range123." Then, on Sheet2, I did the same. As soon as I did that, "Range123" from Sheet1 no longer existed. So, I don't really understand how the user can have the same named ranges within one workbook? You know what, I even took out the reference to Sheet and tried to force in just the cell reference; but Excel won't let me. What am I missing here? Wonder if *two* workbooks are involved when we talk about "same name?"

Sounds like you were talking about VBA. I didn't pick this up.

Look forward to your comments.

Epinn
 
Hi Epinn
Can someone confirm this is not possible please?

That is correct.
You can't have the same name for 2 different ranges, either on the same
sheet or different sheets.

You can have the same range on multiple sheets adopt the same name
provided there is only an exclamation "!" in front of the range, not
Sheet!

--
Regards

Roger Govier


Thank you all for your response. What I want is very simple, nothing to
do with VBA.

Basically, I was trying to have the *same name* for A1:A10 on two sheets
(within the same workbook) respectively. Jim and Biff gave me the
answer.

I don't think I can name A1:A10 on Sheet1 as "ABC" and then also name
B1:B10 on Sheet2 as "ABC" as well. I used insert>name>define and I also
use the Sheet# to qualify the range, but no luck.

Can someone confirm this is not possible please?

The Name Manager may come in handy one of these days. Thanks Dave.

Epinn

Note: This is a continuation of a previous discussion which you don't
really need.

Dave,

I did an experiment. I opened a brand new workbook. On Sheet1, I
selected A1:A10 and defined it with a name "Range123." Then, on Sheet2,
I did the same. As soon as I did that, "Range123" from Sheet1 no longer
existed. So, I don't really understand how the user can have the same
named ranges within one workbook? You know what, I even took out the
reference to Sheet and tried to force in just the cell reference; but
Excel won't let me. What am I missing here? Wonder if *two* workbooks
are involved when we talk about "same name?"

Sounds like you were talking about VBA. I didn't pick this up.

Look forward to your comments.

Epinn
 
If you include the sheet name in the definition, you can have sheet level names
that all use that same ABC name.

While on Sheet1:
Insert Name|Define
Names in workbook: sheet1!ABC
refers to: $a$1

While on Sheet 99 (notice the space):
Insert Name|Define
Names in workbook: 'sheet 99'!ABC (notice the apostrophes)
refers to: $C$12 (it can refer to the same address or not)

I can refer to those range names on sheet7653 by:
=sheet1!ABC+'sheet 99'!ABC

And it'll work fine.
 
You can see the same effect if you set up a print area on different
sheets - the same name "Print_Area" is defined in each sheet, but need
not be the same range from one sheet to another.

Pete
 
Hi Dave

Quite right, but in my eyes those are different named ranges.
Epinn was asking about the same name - which is what I was answering -
and in that case you cannot use the same name to point to 2 different
ranges.
 
I guess it boils down to what you consider the name.

If you create a worksheet level name on Sheet1 named ABC and another worksheet
level name on Sheet2 also named ABC, do they share the same name?
 
do they share the same name?

Not if they rely on Sheet(n)! in front of them to operate, IMO.
 
Finally, I think the light bulb is ___! Glad Roger understood my question and that the dialogue between Dave and Roger helped me sort out a few things. Yes, how do we define "same name?" I'll leave it for another day. The important thing here is I am quite clear now on how to define names.



Yesterday, I said, "Jim and Biff gave me the answer." Today, I said, "Dave and Pete gave me the answer yesterday as well." Sorry for the delay. It took me a while to grasp what you were trying to tell me. I did read about qualifying the range name by the sheet. Unfortunately, I had a different frame of reference. I focused on the bottom part of the "define name" dialogue box which is "Refers to" while you referred to the top part of the dialogue box "Names in workbook." I didn't know that I had to actually key in "Sheet2!" as part of the name. This is why I told you I had no luck using the same name via insert>name>define etc.



Now I have a question on apostrophes.



If I do ctrl+drag of a sheet tab that contains a named range and if I *rename* the duplicate (new) sheet, (e.g. newcopy) then there won't be apostrophes around the sheet name (newcopy) in the define name dialogue box. But if I don't rename the duplicate sheet, say I keep sheet 1(2) as the name, then there will be apostrophes around the sheet name in the define name dialogue box; e.g. 'sheet 1(2)'



I find this confusing.



Dave, you included the following in your posts.







Yes, I pay attention to the apostrophes but I don't understand why sheet99 has apostrophes and sheet1 doesn't. When I include the sheet name without apostrophes, everything seems to work fine as well. Do I really need apostrophes? I am missing something here.



Please help.



Epinn



I think you're in the minority here.

But it does prove that it's good to specify what you mean if there's any doubt.

Roger said:
do they share the same name?

Not if they rely on Sheet(n)! in front of them to operate, IMO.
 
Hi Epinn

If there are any spaces in a sheet name, apostrophe's must be used.
If there no spaces, apostrophe's are not essential but cause no problem
if they are included when typing a formula.

Even if you include them when you create a named range on sheet1 which
referred to say 'Sheet1'!$A$1:$G$20, then Excel removes them and stores
it as Sheet1$A$1:$G$20.
If you then rename sheet1 to My Sheet, Excel will automatically insert
them when it carries out the internal renaming and you will see 'My
Sheet'!$A$1:$G$20 as the new range when you look at named ranges.

When you type a range in a formula, as opposed to referring to its name,
then you MUST use apostrophe's when referring to the sheet name it there
are spaces, otherwise the formula will fail.

--
Regards

Roger Govier


Finally, I think the light bulb is ___! Glad Roger understood my
question and that the dialogue between Dave and Roger helped me sort out
a few things. Yes, how do we define "same name?" I'll leave it for
another day. The important thing here is I am quite clear now on how to
define names.



Yesterday, I said, "Jim and Biff gave me the answer." Today, I said,
"Dave and Pete gave me the answer yesterday as well." Sorry for the
delay. It took me a while to grasp what you were trying to tell me. I
did read about qualifying the range name by the sheet. Unfortunately, I
had a different frame of reference. I focused on the bottom part of the
"define name" dialogue box which is "Refers to" while you referred to
the top part of the dialogue box "Names in workbook." I didn't know
that I had to actually key in "Sheet2!" as part of the name. This is
why I told you I had no luck using the same name via insert>name>define
etc.



Now I have a question on apostrophes.



If I do ctrl+drag of a sheet tab that contains a named range and if I
*rename* the duplicate (new) sheet, (e.g. newcopy) then there won't be
apostrophes around the sheet name (newcopy) in the define name dialogue
box. But if I don't rename the duplicate sheet, say I keep sheet 1(2)
as the name, then there will be apostrophes around the sheet name in the
define name dialogue box; e.g. 'sheet 1(2)'



I find this confusing.



Dave, you included the following in your posts.





Yes, I pay attention to the apostrophes but I don't understand why
sheet99 has apostrophes and sheet1 doesn't. When I include the sheet
name without apostrophes, everything seems to work fine as well. Do I
really need apostrophes? I am missing something here.



Please help.



Epinn



I think you're in the minority here.

But it does prove that it's good to specify what you mean if there's any
doubt.

Roger said:
do they share the same name?

Not if they rely on Sheet(n)! in front of them to operate, IMO.
 
Back
Top