Dear Amresh, Please try it..
Sub RenameTabsHandlingNulls() ' Renames all worksheet tabs with each worksheet's cell A1 contents. 'If cell A1 has no content, then the tab is named as "Default" *Dim sh As String* For i = 1 To Sheets.Count *sh = Left(Worksheets(i).Range("A1").Value, 20)* If Worksheets(i).Range("A1").Value <> "" Then Sheets(i).Name = *sh* Else: Sheets(i).Name = "Default (" & i & ")" End If Next End Sub -- Thanks & regards, Noorain Ansari *http://noorainansari.com/* *http://excelmacroworld.blogspot.com/*<http://excelmacroworld.blogspot.com/> On Fri, Mar 30, 2012 at 7:50 PM, Amresh Maurya <amreshkushw...@gmail.com>wrote: > H Friends, > > I HAVE TO RENAME 72 SHEETS AND I AM USING BELOW CODES FOR RENAME SHEET. > BUT A1 RANGE CHARACTER TOO LONG I WANT RENAME EACH SHEETS HAS 20 CHARACTER > OF RANGE A1. > > PLS CHANGE THE FORMULA AND SEND ME BACK. > > THANKS IN ADVANCE. > > Sub RenameTabsHandlingNulls() > ' Renames all worksheet tabs with each worksheet's cell A1 contents. > 'If cell A1 has no content, then the tab is named as "Default" > > For I = 1 To Sheets.Count > If Worksheets(I).Range("A1").Value <> "" Then > Sheets(I).Name = Worksheets(I).Range("A1").Value > Else: > Sheets(I).Name = "Default (" & I & ")" > End If > Next > End Sub > > Regards > Amresh > > > > -- > FORUM RULES (986+ members already BANNED for violation) > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > > 2) Don't post a question in the thread of another member. > > 3) Don't post questions regarding breaking or bypassing any security > measure. > > 4) Acknowledge the responses you receive, good or bad. > > 5) Cross-promotion of, or links to, forums competitive to this forum in > signatures are prohibited. > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > owners and members are not responsible for any loss. > > > ------------------------------------------------------------------------------------------------------ > To post to this group, send email to excel-macros@googlegroups.com > -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com