Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default adding worksheet name to a named range with VBA?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default adding worksheet name to a named range with VBA?

name1 = Activesheet.Name
Selection.Name = "'" & name1 & "'!ChartColAend"

--
Regards,
Tom Ogilvy


" 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default adding worksheet name to a named range with VBA?

Thanks Tom, sometimes the simple things realy kick my but.

Tom Ogilvy wrote:
name1 = Activesheet.Name
Selection.Name = "'" & name1 & "'!ChartColAend"

--
Regards,
Tom Ogilvy


" 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
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
Ranges, adding a column to a named print range then saving the file [email protected] Excel Programming 1 April 27th 06 01:42 AM
Adding named range gives error "method range of object _Global failed " Gunnar Johansson Excel Programming 3 August 10th 04 01:54 PM
Adding a named range to a cell John[_80_] Excel Programming 1 June 22nd 04 10:51 PM
Adding to a named range on another worksheet Troy[_3_] Excel Programming 1 February 6th 04 08:29 PM
need help adding named range as new series to a graph Keith R[_3_] Excel Programming 1 October 24th 03 09:29 PM


All times are GMT +1. The time now is 03:50 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"