Hi all
I see some people have asked a similar query on renaming tabs with a specific cell's content, and I found the below which almost does what I want.
Sub tabname()
Dim ws As Worksheet
For Each ws In Worksheets
On Error Resume Next
If Len(ws.Range("C2")) > 0 Then
ws.Name = Replace(ws.Range("C2").Value, "Processing: ", "")
End If
On Error GoTo 0
If ws.Name <> Replace(ws.Range("C2").Value, ":", "-") Then
MsgBox ws.Name & " Was Not renamed, the suggested name was invalid"
End If
Next
End Sub
The only problem is that, in two of my four tabs (of course!), the cells I want to reference are in slight different places, and I want to change the names a bit more.
So, in Tab 1, I have a name like "Processing: File Type" in C2, and I want the tab to be named "FileType"
In Tab 2, I have a name like "Processing: File Issues" and in C2, and I want the tab to be called "FileIssues"
In Tab 3, I have a name like "Processing: Document Breakdown Report" in D2, and I want the tab to be called "DocumentType"
In Tab 4, I have a name like "Processing: Random Colours" in E2, and I want the tab to be called "Colours".
Something like that.
The only saving grace, is that the tabs are always in the same order, and the text is always in the cell that I mentioned above, so I am wondering if it is possible to do this.
I see some people have asked a similar query on renaming tabs with a specific cell's content, and I found the below which almost does what I want.
Sub tabname()
Dim ws As Worksheet
For Each ws In Worksheets
On Error Resume Next
If Len(ws.Range("C2")) > 0 Then
ws.Name = Replace(ws.Range("C2").Value, "Processing: ", "")
End If
On Error GoTo 0
If ws.Name <> Replace(ws.Range("C2").Value, ":", "-") Then
MsgBox ws.Name & " Was Not renamed, the suggested name was invalid"
End If
Next
End Sub
The only problem is that, in two of my four tabs (of course!), the cells I want to reference are in slight different places, and I want to change the names a bit more.
So, in Tab 1, I have a name like "Processing: File Type" in C2, and I want the tab to be named "FileType"
In Tab 2, I have a name like "Processing: File Issues" and in C2, and I want the tab to be called "FileIssues"
In Tab 3, I have a name like "Processing: Document Breakdown Report" in D2, and I want the tab to be called "DocumentType"
In Tab 4, I have a name like "Processing: Random Colours" in E2, and I want the tab to be called "Colours".
Something like that.
The only saving grace, is that the tabs are always in the same order, and the text is always in the cell that I mentioned above, so I am wondering if it is possible to do this.