Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default How can I name worksheets in Excel according to named ranges?

I've got a spreadsheet which I need to replicate regularly that contains
about 10 spreadsheets. Each spreadsheet makes use of a different named range
in that spreadsheet. Is there a way to set the worksheet tab name according
to a named range that I've already defined in the spreadsheet? All help much
appreciated. Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 296
Default How can I name worksheets in Excel according to named ranges?

On Mon, 28 Aug 2006 16:28:01 -0700, Dominique
wrote:

I've got a spreadsheet which I need to replicate regularly that contains
about 10 spreadsheets. Each spreadsheet makes use of a different named range
in that spreadsheet. Is there a way to set the worksheet tab name according
to a named range that I've already defined in the spreadsheet? All help much
appreciated. Thank you.


ActiveSheet.Name = Range("MyName")

HTH

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default How can I name worksheets in Excel according to named ranges?

Awesome! Thank you. If I could trouble you for another question:

So, I've written the macro:

Sub MyMacro()
ActiveSheet.Name = Range("MyRange")
End Sub

and then dropped the following into the worksheet code:

Private Sub Worksheet_Activate()
Run "MyMacro"
End Sub

Do you know how I can place the VBscript directly into the worksheet code
without having to create a macro? I ask because I'll have about 30 macros to
create otherwise.

Many, many thanks.
Dominique

"Richard Buttrey" wrote:

On Mon, 28 Aug 2006 16:28:01 -0700, Dominique
wrote:

I've got a spreadsheet which I need to replicate regularly that contains
about 10 spreadsheets. Each spreadsheet makes use of a different named range
in that spreadsheet. Is there a way to set the worksheet tab name according
to a named range that I've already defined in the spreadsheet? All help much
appreciated. Thank you.


ActiveSheet.Name = Range("MyName")

HTH

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 296
Default How can I name worksheets in Excel according to named ranges?

The macro does not have to be triggered by a Worksheet Activate event.
That was only a suggestion

If the named range containing the name you want for the sheet is
always in the same position, (say A1 in the example below), the
following macro could be placed in a module procedure. e.g.


Sub NameSheets()
Dim x As Integer
For x = 1 To ActiveWorkbook.Sheets.Count
If Worksheets(x).Range("A1") < "" Then
Worksheets(x).Name = Worksheets(x).Range("A1")
End If
Next x
End Sub

It loops through every sheet and names the sheet accoding to the
contents of A1. You might need to modify this if other sheets that you
don't want to rename have something in A1. The trick is to have
something consistent about the sheets in question and unique to them.
Trivially you could mark each sheet to be renamed with say an 'x' in
Z1, then the test becomes

If Worksheets(x).Range("Z1") = "x" Then

HTH.


On Tue, 29 Aug 2006 00:46:02 -0700, Dominique
wrote:

Awesome! Thank you. If I could trouble you for another question:

So, I've written the macro:

Sub MyMacro()
ActiveSheet.Name = Range("MyRange")
End Sub

and then dropped the following into the worksheet code:

Private Sub Worksheet_Activate()
Run "MyMacro"
End Sub

Do you know how I can place the VBscript directly into the worksheet code
without having to create a macro? I ask because I'll have about 30 macros to
create otherwise.

Many, many thanks.
Dominique

"Richard Buttrey" wrote:

On Mon, 28 Aug 2006 16:28:01 -0700, Dominique
wrote:

I've got a spreadsheet which I need to replicate regularly that contains
about 10 spreadsheets. Each spreadsheet makes use of a different named range
in that spreadsheet. Is there a way to set the worksheet tab name according
to a named range that I've already defined in the spreadsheet? All help much
appreciated. Thank you.


ActiveSheet.Name = Range("MyName")

HTH

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________


__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default How can I name worksheets in Excel according to named ranges?

Wow! The perfect solution to the problem. Thank you so very much!! You're
absolutely right about having it in the workbook module...you're my new
favorite person of the day, btw!

Regards, Dominique

"Richard Buttrey" wrote:

The macro does not have to be triggered by a Worksheet Activate event.
That was only a suggestion

If the named range containing the name you want for the sheet is
always in the same position, (say A1 in the example below), the
following macro could be placed in a module procedure. e.g.


Sub NameSheets()
Dim x As Integer
For x = 1 To ActiveWorkbook.Sheets.Count
If Worksheets(x).Range("A1") < "" Then
Worksheets(x).Name = Worksheets(x).Range("A1")
End If
Next x
End Sub

It loops through every sheet and names the sheet accoding to the
contents of A1. You might need to modify this if other sheets that you
don't want to rename have something in A1. The trick is to have
something consistent about the sheets in question and unique to them.
Trivially you could mark each sheet to be renamed with say an 'x' in
Z1, then the test becomes

If Worksheets(x).Range("Z1") = "x" Then

HTH.


On Tue, 29 Aug 2006 00:46:02 -0700, Dominique
wrote:

Awesome! Thank you. If I could trouble you for another question:

So, I've written the macro:

Sub MyMacro()
ActiveSheet.Name = Range("MyRange")
End Sub

and then dropped the following into the worksheet code:

Private Sub Worksheet_Activate()
Run "MyMacro"
End Sub

Do you know how I can place the VBscript directly into the worksheet code
without having to create a macro? I ask because I'll have about 30 macros to
create otherwise.

Many, many thanks.
Dominique

"Richard Buttrey" wrote:

On Mon, 28 Aug 2006 16:28:01 -0700, Dominique
wrote:

I've got a spreadsheet which I need to replicate regularly that contains
about 10 spreadsheets. Each spreadsheet makes use of a different named range
in that spreadsheet. Is there a way to set the worksheet tab name according
to a named range that I've already defined in the spreadsheet? All help much
appreciated. Thank you.

ActiveSheet.Name = Range("MyName")

HTH

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________


__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________

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
Viewing Named Ranges Rob Moyle Excel Discussion (Misc queries) 4 June 8th 06 11:41 AM
TRYING TO SET UP EXCEL SPREADSHEET ON MY COMPUTER MEGTOM New Users to Excel 5 October 27th 05 03:06 AM
Accessing named ranges in Excel from VBA Basz Excel Discussion (Misc queries) 1 August 10th 05 03:21 PM
Macro (Print) - Calling Named Ranges KGlennC Excel Discussion (Misc queries) 1 March 19th 05 09:20 PM
Named dynamic ranges, copied worksheets and graph source data WP Charts and Charting in Excel 1 November 28th 04 05:19 PM


All times are GMT +1. The time now is 05:17 PM.

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"