Jak
Well-known Member
- Joined
- Apr 5, 2002
- Messages
- 833
Hi
I am using the code below to rename worksheet tabs based on the value in cell B3 on each worksheet. I am getting a run time error attributed to the value in cell B3 exceeding 31 characters. This is the maximum number of characters a worksheet tab can support. Could anyone help with some additional code to rename the worksheet tabs and trim the name when 31 character limit is reached? Please note I need to keep the value in cell B3 as it is but trim the worksheet tab name only. I hope this is clear and someone can help me with this.
I am using the code below to rename worksheet tabs based on the value in cell B3 on each worksheet. I am getting a run time error attributed to the value in cell B3 exceeding 31 characters. This is the maximum number of characters a worksheet tab can support. Could anyone help with some additional code to rename the worksheet tabs and trim the name when 31 character limit is reached? Please note I need to keep the value in cell B3 as it is but trim the worksheet tab name only. I hope this is clear and someone can help me with this.
Code:
For I = 1 To Sheets.Count
If Worksheets(I).Range("B3").Value <> "" Then
Sheets(I).Name = Worksheets(I).Range("B3").Value
Else:
Sheets(I).Name = "Default (" & I & ")"
End If
Next