Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default How do I define the same name to a number of different worksheets.

I created a worksheet with named cells and ranges and used a macro to
organize data within the worksheet. I then copied the sheet several times.
The named cells and ranges are valid for each separate sheet and the macro
runs independently for each active sheet using the same control keys. I've
been trying to add another range name that would be common to each seperate
worksheet that would be referenced by the macro just as the original cells
and ranges are, but the name becomes specific to the last sheet that the
name was defined on. How do I define names that apply to each sheet
independently. If I can't resolve this problem I will have to develop a
seperate macro for each worksheet in the workbook.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default How do I define the same name to a number of different worksheets.

Hi Malcolm,
Not sure i understand what you're trying to do.
Can you give an example of the end result?

Are you trying to create book-level or sheet-level named ranges?

- book level is, eg, MyName pointing to sheet1!A1 and everywhere you call
MyName in the book , it points to sheet1!A1

- sheet level. Eg: You can create a name, say MyName in sheet1 pointing to
Sheet1!A1. From sheet1, you call it using MyName, but from other sheets, it
is not directly 'visible' and to call it youu need to call it Sheet1!MyName.
The extension of that is:
- In sheet1, you can call MyName the cell A1
- In sheet2, you can call MyName the cell A1
Now, when using the names:
- in sheet1, =MyName returns Sheet1!MyName = sheet1!A1
- in sheet2, =MyName returns Sheet2!MyName = sheet2!A1
This allows you to use the same formula in all sheets (=MyName) but each
point to a different range (based on in which sheet the name is defined)

Manually set a sheet-level name:
- Select Sheet1. Menu Insert Name Define.
- for Name, enter: Sheet1!Data
- for RefersTo, enter: =Sheet1!A1
- click Add, click OK
- Select Sheet2. Menu Insert Name Define
- for Name , enter: Sheet2!Data
- for RefersTo, enter: =Sheey2!A1
- click Add , click OK
- Now in sheet1!A1 and in Sheet2!A2 enter 2 different values and somewhere
else in both sheets , enter =Data.

Same programmatically:
ActiveWorkbook.Names.Add Name:="sheet2!Data", RefersTo:="=Sheet2!$A$1"
ActiveWorkbook.Names.Add Name:="sheet1!Data", RefersTo:="=Sheet1!$A$1"

Regards,
Sebastien


"Malcolm" wrote:

I created a worksheet with named cells and ranges and used a macro to
organize data within the worksheet. I then copied the sheet several times.
The named cells and ranges are valid for each separate sheet and the macro
runs independently for each active sheet using the same control keys. I've
been trying to add another range name that would be common to each seperate
worksheet that would be referenced by the macro just as the original cells
and ranges are, but the name becomes specific to the last sheet that the
name was defined on. How do I define names that apply to each sheet
independently. If I can't resolve this problem I will have to develop a
seperate macro for each worksheet in the workbook.

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
Repeat text a number define of times Alexandra Lopes Excel Worksheet Functions 6 November 18th 08 05:37 PM
Using the numeric contents of a cell to define row number JRD Excel Worksheet Functions 4 December 12th 07 10:24 PM
Use a formula to define row number INeedID Excel Discussion (Misc queries) 2 June 13th 07 12:33 AM
Define list of worksheets Judy Ward Excel Worksheet Functions 4 June 15th 05 09:44 PM
Globally define all Excel worksheets as text Paul Excel Programming 2 January 29th 04 09:42 PM


All times are GMT +1. The time now is 11:22 PM.

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"