C
Chris Mitchell
I have a workbook that contains 29 sheets.
I want to rename sheets 3 to 27, with names from specified cells on sheet
29.
The names will be made from the concatenation of the contents of 2 cells on
sheet 1.
I got a macro from this NG some time ago that used to do the job, but the
workbook has changed substantially since then with new sheets having been
added and others deleted.
When I list the Macros I have 2; Sheet35.fid and Sheet35.listsheets. These
are both the same as follows:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 3 Or Target.Column <> 2 Then Exit Sub
On Error Resume Next
Application.EnableEvents = False
Sheets(Target.Row).Name = Target
Application.EnableEvents = True
End Sub
Sub fid()
Application.EnableEvents = True
End Sub
Sub listsheets()
Range("b3:b" & Cells(Rows.Count, "b").End(xlUp).Row).Clear
For i = 1 To Worksheets.Count
'MsgBox Sheets(i).Name
If Sheets(i).Name <> "TEMPLATE" And _
Sheets(i).Name <> "VALIDATION" And _
Sheets(i).Name <> "Summary" And _
Sheets(i).Name <> "DataEntry" Then
Cells(i + 0, "b") = Sheets(i).Name
End If
Next i
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Application.DisplayAlerts = False
Dim WantedSheet As String
WantedSheet = Trim(ActiveCell.Value)
If WantedSheet = "" Then Exit Sub
On Error Resume Next
If Sheets(ActiveCell.Value) Is Nothing Then
'GetWorkbook ' calls another macro to do that
Else
Sheets(ActiveCell.Value).Select
ActiveSheet.Range("a11").Select
End If
Application.DisplayAlerts = True
End Sub
This works for the first sheet to be renamed, but not any others.
When I step into it 'Sub listsheets()' is highlighted.
I don't understand macros, yet, so don't know if this is broken in some way.
Can anyone see anything wrong with this macro, or suggest another macro or a
better non-macro way of achieving this?
TIA.
Chris.
I want to rename sheets 3 to 27, with names from specified cells on sheet
29.
The names will be made from the concatenation of the contents of 2 cells on
sheet 1.
I got a macro from this NG some time ago that used to do the job, but the
workbook has changed substantially since then with new sheets having been
added and others deleted.
When I list the Macros I have 2; Sheet35.fid and Sheet35.listsheets. These
are both the same as follows:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 3 Or Target.Column <> 2 Then Exit Sub
On Error Resume Next
Application.EnableEvents = False
Sheets(Target.Row).Name = Target
Application.EnableEvents = True
End Sub
Sub fid()
Application.EnableEvents = True
End Sub
Sub listsheets()
Range("b3:b" & Cells(Rows.Count, "b").End(xlUp).Row).Clear
For i = 1 To Worksheets.Count
'MsgBox Sheets(i).Name
If Sheets(i).Name <> "TEMPLATE" And _
Sheets(i).Name <> "VALIDATION" And _
Sheets(i).Name <> "Summary" And _
Sheets(i).Name <> "DataEntry" Then
Cells(i + 0, "b") = Sheets(i).Name
End If
Next i
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Application.DisplayAlerts = False
Dim WantedSheet As String
WantedSheet = Trim(ActiveCell.Value)
If WantedSheet = "" Then Exit Sub
On Error Resume Next
If Sheets(ActiveCell.Value) Is Nothing Then
'GetWorkbook ' calls another macro to do that
Else
Sheets(ActiveCell.Value).Select
ActiveSheet.Range("a11").Select
End If
Application.DisplayAlerts = True
End Sub
This works for the first sheet to be renamed, but not any others.
When I step into it 'Sub listsheets()' is highlighted.
I don't understand macros, yet, so don't know if this is broken in some way.
Can anyone see anything wrong with this macro, or suggest another macro or a
better non-macro way of achieving this?
TIA.
Chris.