Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default ActiveWorkbook.Names.Add Name ???

2 Questions :

1 How do i refer to the cells wich are currently selected ?

So, i want to assign a name to the cells which are selected.


2 Is it possible to assign the same name to ranges in different worksheets ?
Example : i have sheets "Step 1" to......"Step xx"
I want a name assigned to a range in "Step 1", but that name can also
exist in the sheet "Step 1" or "Step xx".


Thanks,

Luc

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default ActiveWorkbook.Names.Add Name ???

Is it possible to assign the name name to ranges on different worksheets?

You bet, as long as the scope of the name is the worksheet of interest. In
Excel 2007, under FORMULAS - DEFINE NAME, it defaults to WORKBOOK, but you
can change it to the worksheet of interest.

If you want to do it programmatically, do something like this

aWS.Names.Add Name:=myRangeString, RefersTo:=myRefersTo

I've defined myRefersto this way in my code

myRefersTo = "='" & aWS.Name & "'!" &
myRange.AddressLocal(ReferenceStyle:=xlA1)

where myRange defined as a range in my code.


HTH,

Barb Reinhardt



"Luc" wrote:

2 Questions :

1 How do i refer to the cells wich are currently selected ?

So, i want to assign a name to the cells which are selected.


2 Is it possible to assign the same name to ranges in different worksheets ?
Example : i have sheets "Step 1" to......"Step xx"
I want a name assigned to a range in "Step 1", but that name can also
exist in the sheet "Step 1" or "Step xx".


Thanks,

Luc

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default ActiveWorkbook.Names.Add Name ???

Is this also for Excel 2003 ?

Luc




"Barb Reinhardt" schreef in
bericht ...
Is it possible to assign the name name to ranges on different worksheets?

You bet, as long as the scope of the name is the worksheet of interest.
In
Excel 2007, under FORMULAS - DEFINE NAME, it defaults to WORKBOOK, but
you
can change it to the worksheet of interest.

If you want to do it programmatically, do something like this

aWS.Names.Add Name:=myRangeString, RefersTo:=myRefersTo

I've defined myRefersto this way in my code

myRefersTo = "='" & aWS.Name & "'!" &
myRange.AddressLocal(ReferenceStyle:=xlA1)

where myRange defined as a range in my code.


HTH,

Barb Reinhardt



"Luc" wrote:

2 Questions :

1 How do i refer to the cells wich are currently selected ?

So, i want to assign a name to the cells which are selected.


2 Is it possible to assign the same name to ranges in different
worksheets ?
Example : i have sheets "Step 1" to......"Step xx"
I want a name assigned to a range in "Step 1", but that name can also
exist in the sheet "Step 1" or "Step xx".


Thanks,

Luc

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default ActiveWorkbook.Names.Add Name ???

Never mind, it figured it out :

ActiveSheet.Names.Add Name:="Asbest", RefersTo:=Selection



"Luc" schreef in bericht
...
Is this also for Excel 2003 ?

Luc




"Barb Reinhardt" schreef in
bericht ...
Is it possible to assign the name name to ranges on different worksheets?

You bet, as long as the scope of the name is the worksheet of interest.
In
Excel 2007, under FORMULAS - DEFINE NAME, it defaults to WORKBOOK, but
you
can change it to the worksheet of interest.

If you want to do it programmatically, do something like this

aWS.Names.Add Name:=myRangeString, RefersTo:=myRefersTo

I've defined myRefersto this way in my code

myRefersTo = "='" & aWS.Name & "'!" &
myRange.AddressLocal(ReferenceStyle:=xlA1)

where myRange defined as a range in my code.


HTH,

Barb Reinhardt



"Luc" wrote:

2 Questions :

1 How do i refer to the cells wich are currently selected ?

So, i want to assign a name to the cells which are selected.


2 Is it possible to assign the same name to ranges in different
worksheets ?
Example : i have sheets "Step 1" to......"Step xx"
I want a name assigned to a range in "Step 1", but that name can also
exist in the sheet "Step 1" or "Step xx".


Thanks,

Luc

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default ActiveWorkbook.Names.Add Name ???

Selection.name = "Step1"
will create a global/workbook level name.

with selection
.name = "'" & .parent.name & "'!" & "Step1"
end with
will create a local/worksheet level name.

And it's not necessary to select the range to work with it.

with worksheets("sheet999").range("A1")
.name = "'" & .parent.name & "'!" & "Step1"
end with

Luc wrote:

2 Questions :

1 How do i refer to the cells wich are currently selected ?

So, i want to assign a name to the cells which are selected.

2 Is it possible to assign the same name to ranges in different worksheets ?
Example : i have sheets "Step 1" to......"Step xx"
I want a name assigned to a range in "Step 1", but that name can also
exist in the sheet "Step 1" or "Step xx".

Thanks,

Luc


--

Dave Peterson


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
Get Names of ActiveWorkbook.CustomViews cellist Excel Programming 2 April 30th 08 07:02 AM
ActiveWorkbook.Names.Add -- Problem Ger[_3_] Excel Programming 6 February 23rd 07 09:32 AM
Mutiple names in ActiveWorkbook.SendMail Recipients:= daleatshel Excel Discussion (Misc queries) 2 February 5th 07 08:06 PM
'ActiveWorkbook.Names.Add Name:' how to make range variable? TeeSea Excel Programming 1 June 9th 05 03:42 PM
Using ActiveWorkbook.Names.Add Name:= Stuart[_5_] Excel Programming 2 November 15th 03 02:38 PM


All times are GMT +1. The time now is 06:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"