Rename of sheets by macro

  • Thread starter Thread starter Harshad
  • Start date Start date
H

Harshad

i have Sheet1 to Sheet 55 in my workbook.

I want Sheet1 rename as Main, sheet2 as Content, sheet3 as Micro, sheet4 as
Help, sheet5 as NN1, sheet6 to sheet55 as NN2 to NN50.

Sugest macro.

Thanks
 
Try this

Sub renamesheets()
Sheets("sheet1").Name = "Main"
'etc

For i = 5 To Sheets.Count
'Help, sheet5 as NN1, sheet6 to sheet55 as NN2 to NN50.
Sheets("sheet" & i).Name = "NN" & i - 4
Next i
End Sub
 
Why not do it all in one go when you add them

Sub Sheet_addition()
Dim i As Long
On Error GoTo endit
Application.ScreenUpdating = False
For i = 1 To 52
Sheets.Add after:=Sheets(i)
If i > 1 Then ActiveSheet.Name = "NN" & i - 1
Next i
endit:
Sheets("Sheet1").Name = "Main"
Sheets("Sheet2").Name = "Content"
Sheets("Sheet3").Name = "Micro"
Sheets("Sheet4").Name = "Help"
Application.ScreenUpdating = True
End Sub

Mike
 
Dear Mike & Don,

Don,
Your macro works very fine. Thank you.

Mike,
It's very nice that i can utilize both macro in a single code. It also works
very fine, but again the problem of sheet order is there.
I want it as order : Main, Content, Micro, Help, NN1, NN2.......NN51.

But it shows the order: Main, Help, NN1, NN2,...,NN51, Content, Micro.

Kindly revert back.
 
Back
Top