albytross
New Member
- Joined
- Sep 22, 2021
- Messages
- 24
- Office Version
- 365
Hi,
I have this code which successfully renames my worksheets.
Its two parts:
1. first it adds underscores to the existing names
2. then it prefixes all worksheets with the value from cell C9.
How can i make the code skip both stages of renaming for a worksheet called "SKIP_ME"?
So that SKIP_ME is not renamed at all.
I have this code which successfully renames my worksheets.
Its two parts:
1. first it adds underscores to the existing names
2. then it prefixes all worksheets with the value from cell C9.
How can i make the code skip both stages of renaming for a worksheet called "SKIP_ME"?
So that SKIP_ME is not renamed at all.
VBA Code:
Sub RenameWorksheets()
Dim xWs As Worksheet
' Part one - add underscore to worksheet names
Sheets("Casing").Name = "_Cars"
Sheets("Collar").Name = "_Houses"
Sheets("DownholeSurvey").Name = "_Animals"
'Part two - adds cell value C9 as prefix to all worksheet names
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
sh.Name = Range("C9") & sh.Name
Next sh
End Sub