muhleebbin
Active Member
- Joined
- Sep 30, 2017
- Messages
- 252
- Office Version
- 365
- 2019
- 2016
- 2013
- 2010
- Platform
- Windows
- MacOS
- Mobile
- Web
Can someone help me figure out the code to rename just part of a sheet name while keeping the rest?
Current code is as follows but the original sheet name has a location description after the 4th character and would like to keep that. Plus this just tries to rename each sheet that contains A1 value to B1 value and runs into "The name is already taken error"
Thanks in advance for your assistance!
Current code is as follows but the original sheet name has a location description after the 4th character and would like to keep that. Plus this just tries to rename each sheet that contains A1 value to B1 value and runs into "The name is already taken error"
Thanks in advance for your assistance!
VBA Code:
Sub RenameSheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
With ws
If Left(.Name, 4) = Sheets("Lists").Range("A1").Value Then .Name = Left(Sheets("Lists").Range("B1").Value, 4)
End With
Next ws
End Sub