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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
41,065
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
41,065
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,099,751
Messages
5,470,566
Members
406,705
Latest member
JBram

This Week's Hot Topics

Top