renaming excel sheets with vba

jazzD

New Member
Joined
May 3, 2019
Messages
18
hi,

i am trying to do some macro on an existing report in excel - its a client account statement - if the client has multiple accounts it will seperate them out into sheets and name each sheet for example John, John 1, John 2, John 3, john 4. depending on the client there could be 2 sheets or 10 sheets. i am looking to rename all sheets back to sheet 1, sheet 2, sheet 3 to keep it generic. is that possible?

thanks,
 

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,977
Office Version
365
Platform
Windows
How about
Code:
Sub jazzD()
   Dim i As Long
   
   For i = 1 To Sheets.Count
      Sheets(i).Name = "Sheet " & i
   Next i
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,977
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,099,609
Messages
5,469,683
Members
406,665
Latest member
priyankape2005

This Week's Hot Topics

Top