I am naming sheets using :
arrayCollabName = Array("CBDeltaBlockStatus_SAP03_to_Delta01", "CBDeltaBlockStatus_SAP03_to_Delta02", "CBDeltaDeliveryInformation_SAP03_to_Delta01")
If Len(arrayCollabName(idx)) > 31 Then
ActiveSheet.Name = Left(arrayCollabName(idx), 31)
Else
ActiveSheet.Name = arrayCollabName(idx)
End If
In the array 1st and 2nd names are similar when the name gets truncated to 31 characters and VB is throwing the error “Cannot rename the sheet to the same name as another sheet, a referenced object library or a workbook referenced by visualbasic.”
Any way I can do this without error and name the sheets as CBDeltaBlock_SAP03_to_Delta01 and CBDeltaBlock_SAP03_to_Delta02 or any desired name.
Here is an example to change the sheet name if it already exists.
The above method will add a random number at the end of the sheet. If you want in increasing order then use the below code.
NOTE: The above code are just sample codes. Error Handling has not been incorporated in the above code and needless to say that Error handling is a must 🙂