ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Defining identical names that represent different ranges of cells (https://www.excelbanter.com/excel-discussion-misc-queries/107804-defining-identical-names-represent-different-ranges-cells.html)

Bernard

Defining identical names that represent different ranges of cells
 
Is there a way to define, within the same workbook, identical names that
relate to different ranges, depending on the sheet they belong to.
For instance : The name "Area" would refer to cells Sheet1!A1:A2 when
invoked from within Sheet1, or to cells Sheet2!B1:B2 when invoked from within
Sheet2.
This would let identical formulas provide different results according to the
sheet they reside in.

Such a definition is quite straightforward using VBA, something like :
ThisWorkbook.Worksheets(1).Names.Add RefersTo:="=A1:A2", Name:="Area"
ThisWorkbook.Worksheets(2).Names.Add RefersTo:="=B1:B2", Name:="Area"

But I'm actually looking for a direct Excel method, not using VBA.

Thanks for any idea

Bob Umlas

Defining identical names that represent different ranges of cells
 
Include the sheet tab in the definition of the range:
Insert/Name/Define:
Sheet1!Area refers to
Sheet1!A1:A1

Sheet2!Area refers to
Sheet2!B2:B2
etc.

"Bernard" wrote in message
...
Is there a way to define, within the same workbook, identical names that
relate to different ranges, depending on the sheet they belong to.
For instance : The name "Area" would refer to cells Sheet1!A1:A2 when
invoked from within Sheet1, or to cells Sheet2!B1:B2 when invoked from

within
Sheet2.
This would let identical formulas provide different results according to

the
sheet they reside in.

Such a definition is quite straightforward using VBA, something like :
ThisWorkbook.Worksheets(1).Names.Add RefersTo:="=A1:A2", Name:="Area"
ThisWorkbook.Worksheets(2).Names.Add RefersTo:="=B1:B2", Name:="Area"

But I'm actually looking for a direct Excel method, not using VBA.

Thanks for any idea




Bernard

Defining identical names that represent different ranges of ce
 
Thanks, The simpler, the better ! I should have guessed that !
By the way this sould be documented in the on line help.

"Bob Umlas" wrote:

Include the sheet tab in the definition of the range:
Insert/Name/Define:
Sheet1!Area refers to
Sheet1!A1:A1

Sheet2!Area refers to
Sheet2!B2:B2
etc.

"Bernard" wrote in message
...
Is there a way to define, within the same workbook, identical names that
relate to different ranges, depending on the sheet they belong to.
For instance : The name "Area" would refer to cells Sheet1!A1:A2 when
invoked from within Sheet1, or to cells Sheet2!B1:B2 when invoked from

within
Sheet2.
This would let identical formulas provide different results according to

the
sheet they reside in.

Such a definition is quite straightforward using VBA, something like :
ThisWorkbook.Worksheets(1).Names.Add RefersTo:="=A1:A2", Name:="Area"
ThisWorkbook.Worksheets(2).Names.Add RefersTo:="=B1:B2", Name:="Area"

But I'm actually looking for a direct Excel method, not using VBA.

Thanks for any idea






All times are GMT +1. The time now is 11:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com