PC Review


Reply
Thread Tools Rate Thread

adding worksheet name to a named range with VBA?

 
 
robert.hatcher@l-3com.com
Guest
Posts: n/a
 
      20th Oct 2006
In a VBA script I need to add the active worksheet name, to a named
range that the script is building.

This works fine:

'Assign a Name to the last cell used in column A
'select the very last used cell in a Column:

Range("A65536").End(xlUp).Select
'assign a Name to the selection
'Selection.Name = "Htestc!ChartColAend"

However, I need to this code to run on several sheets so I want to
define the worksheet name as a variable and then have the value of the
variable be part of the name.

I'm trying this:

Dim Name1
name1 = ActiveSheet.Name

Range("A65536").End(xlUp).Select


Selection.Name = "worksheets(""name1"")!ChartColAend"

and

Selection.Name = "worksheets(""name1"").value!ChartColAend"

To no avail.

I'm lost again, any help will be appreciated
Thanks
Robert

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      20th Oct 2006
name1 = Activesheet.Name
Selection.Name = "'" & name1 & "'!ChartColAend"

--
Regards,
Tom Ogilvy


"(E-Mail Removed)" wrote:

> In a VBA script I need to add the active worksheet name, to a named
> range that the script is building.
>
> This works fine:
>
> 'Assign a Name to the last cell used in column A
> 'select the very last used cell in a Column:
>
> Range("A65536").End(xlUp).Select
> 'assign a Name to the selection
> 'Selection.Name = "Htestc!ChartColAend"
>
> However, I need to this code to run on several sheets so I want to
> define the worksheet name as a variable and then have the value of the
> variable be part of the name.
>
> I'm trying this:
>
> Dim Name1
> name1 = ActiveSheet.Name
>
> Range("A65536").End(xlUp).Select
>
>
> Selection.Name = "worksheets(""name1"")!ChartColAend"
>
> and
>
> Selection.Name = "worksheets(""name1"").value!ChartColAend"
>
> To no avail.
>
> I'm lost again, any help will be appreciated
> Thanks
> Robert
>
>

 
Reply With Quote
 
robert.hatcher@l-3com.com
Guest
Posts: n/a
 
      20th Oct 2006
Thanks Tom, sometimes the simple things realy kick my but.

Tom Ogilvy wrote:
> name1 = Activesheet.Name
> Selection.Name = "'" & name1 & "'!ChartColAend"
>
> --
> Regards,
> Tom Ogilvy
>
>
> "(E-Mail Removed)" wrote:
>
> > In a VBA script I need to add the active worksheet name, to a named
> > range that the script is building.
> >
> > This works fine:
> >
> > 'Assign a Name to the last cell used in column A
> > 'select the very last used cell in a Column:
> >
> > Range("A65536").End(xlUp).Select
> > 'assign a Name to the selection
> > 'Selection.Name = "Htestc!ChartColAend"
> >
> > However, I need to this code to run on several sheets so I want to
> > define the worksheet name as a variable and then have the value of the
> > variable be part of the name.
> >
> > I'm trying this:
> >
> > Dim Name1
> > name1 = ActiveSheet.Name
> >
> > Range("A65536").End(xlUp).Select
> >
> >
> > Selection.Name = "worksheets(""name1"")!ChartColAend"
> >
> > and
> >
> > Selection.Name = "worksheets(""name1"").value!ChartColAend"
> >
> > To no avail.
> >
> > I'm lost again, any help will be appreciated
> > Thanks
> > Robert
> >
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do not specify worksheet in a named range =?Utf-8?B?aG1t?= Microsoft Excel Misc 3 18th Sep 2007 01:30 PM
Getting a named range to appear in another worksheet =?Utf-8?B?Sm9obg==?= Microsoft Excel Misc 2 28th Jul 2007 02:12 AM
Using Named Range with protection on the worksheet =?Utf-8?B?dHhqYWcwMDc=?= Microsoft Excel Misc 1 7th Sep 2006 11:54 AM
Adding a named range Stephen Boulet Microsoft Excel Programming 2 15th Mar 2004 11:16 PM
Adding to a named range on another worksheet =?Utf-8?B?VHJveQ==?= Microsoft Excel Programming 1 6th Feb 2004 08:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:01 AM.