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.
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
Grappenhall, Cheshire, UK
__________________________