Resetting Default Names for New Worksheets

Written by Allen Wyatt (last updated May 13, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365


Peter developed a macro that deletes all the worksheets in a workbook except for one named "Index." This macro works fine. However, after running the macro, if he adds a new worksheet he expects it to be named "Sheet1" as the default, but it is actually named a later number, such as "Sheet3" or "Sheet4." Peter wonders what is required to reset the sheet numbering to the expected default.

The easiest way to reset the sheet numbering is to simply close the workbook and open it again. That, however, involves a manual step on your part. If you are adding the new worksheets via macro, then you probably don't want to manually close and re-open the workbook.

You could, if desired, create a simple macro to do the close and re-open process. This will work as long as the macro is stored in your Personal Macro Workbook and not in the workbook you are closing.

Sub Reopen()
    Dim wb As Excel.Workbook
    Dim sPath As String

    Set wb = ThisWorkbook
    sPath = wb.FullName

    Application.OnTime Now + TimeValue("00:00:01"), _
      Application.Workbooks.Open(sPth)
    wb.Close (True)
End Sub

The macro determines the name of the current workbook and then sets an OnTime event to open the workbook 1 second in the future. During that 1 second, however, the workbook is closed and saved, which allows it to be re-opened successfully.

You could, if desired, also choose to add your new worksheets via macro. The following short macro adds a worksheet and then immediately renames it to the desired name.

Sub AddWs()
  Worksheets.Add after:=Sheets(Sheets.Count)
  Sheets(Sheets.Count).Name = "Sheet" & Sheets.Count - 1
End Sub

You'll want to play with these solutions and find which one works best for your needs, particularly if you are wanting to integrate the solution with an already existing macro.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (6103) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Controlling Endnote Placement

Endnotes are often used in technical and scholarly documents. You can control exactly where the endnotes appear in your ...

Discover More

Viewing Workbook Statistics

Excel keeps track of a range of stats about each workbook you use. If you want to take a look at those stats, it's easy; ...

Discover More

Importing Huge Data Files

Sometimes, when importing data created by other programs, you may find that there is too much for Excel to handle. Here's ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Finding Workbooks Containing Macros

Workbooks can contain macros, or not. It is entirely up to you whether they do or not, but at some future time you might ...

Discover More

Magnifying Only the Current Cell

You can use the Zoom feature of Excel to magnify what Excel shows of your workbook, but it affects the entire screen. ...

Discover More

Unprotecting Groups of Worksheets

Unprotecting a single worksheet is relatively easy. Unprotecting a whole lot of worksheets is harder. Here's how you can ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is three more than 2?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.