Hi all
I've culled the following macro from a number of other sources to rename a sheet according to the text in cell C8 on that sheet
It works great. However, some of the data would lead to sheets being named identically, which throws out the macro. How can I update this macro so that it renames the second sheet with a (2) after the name?
In other words, gives me sheets called ABC Ltd and ABC Ltd (2) if two sheets have ABC Ltd in cell C8?
Thanks
Matt
I've culled the following macro from a number of other sources to rename a sheet according to the text in cell C8 on that sheet
Sub Macro1()
z = Sheets.Count
For x = 1 To z
a = Sheets(x).Range("C8").Value
Sheets(x).Name = Left(a, 25)
Next
End Sub
z = Sheets.Count
For x = 1 To z
a = Sheets(x).Range("C8").Value
Sheets(x).Name = Left(a, 25)
Next
End Sub
It works great. However, some of the data would lead to sheets being named identically, which throws out the macro. How can I update this macro so that it renames the second sheet with a (2) after the name?
In other words, gives me sheets called ABC Ltd and ABC Ltd (2) if two sheets have ABC Ltd in cell C8?
Thanks
Matt