tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,194
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I have macro that works great but every now and then a sheet name is chosen that is already in use.
Is it posible to add i a part that checks if the names in use and if so adds a number at the end
so if sheet name was "Tony" it would do "Tony 2"
starting at 2 so it shows its the second one?
heres my code:
Sub Copy_Sheet()
Application.EnableEvents = False
Sheets("Template").Copy After:=ActiveSheet
ActiveSheet.Name = ActiveSheet.Range("G7")
Application.EnableEvents = True
End Sub
I have macro that works great but every now and then a sheet name is chosen that is already in use.
Is it posible to add i a part that checks if the names in use and if so adds a number at the end
so if sheet name was "Tony" it would do "Tony 2"
starting at 2 so it shows its the second one?
heres my code:
Sub Copy_Sheet()
Application.EnableEvents = False
Sheets("Template").Copy After:=ActiveSheet
ActiveSheet.Name = ActiveSheet.Range("G7")
Application.EnableEvents = True
End Sub