How to change the default template for new sheets in Excel using VBA?

Changing the default template for new sheets in Excel involves saving a template file that Excel uses whenever a new sheet is created. This cannot be done directly using VBA alone, but you can automate some steps using VBA. Here’s a general approach on how to change the default template for new sheets:

Step-by-Step Guide

       C:Users<YourUsername>AppDataRoamingMicrosoftExcelXLSTART
       /Applications/Microsoft Office 2011/Office/Startup/Excel/
  • Create a New Workbook:
    • Open Excel and create a new workbook. Customize the worksheet as needed (formatting, styles, headers, footers, etc.).
  • Save as Template:
    • Go to `File > Save As`.
    • In the `Save as type` dropdown, select `Excel Template (*.xltx)`.
    • Name the file `Sheet.xltx`.
    • Save it in the Excel startup folder:
    • For Windows, this is typically located at:
    • For Mac, you can use:
  • Test the New Default Sheet Template:
    • Open a new workbook and add a new sheet (e.g., by clicking on the “+” icon next to the existing sheet tab).
    • The new sheet should reflect the customizations you set in the `Sheet.xltx` template.

Using VBA to Automate Template Creation (Optional)

If you wish to use VBA for any part of this process, such as automating the creation of your template, you can use a macro to help customize the sheet before you save it as a template. Here’s a simple example:

Sub CreateCustomSheetTemplate()
    Dim ws As Worksheet
    
    ' Create a new workbook and work on the first sheet
    Set ws = Workbooks.Add.Worksheets(1)
    
    ' Apply customizations
    With ws
        .Cells.Font.Name = "Calibri"
        .Cells.Font.Size = 11
        .Range("A1").Value = "Title"
        .Range("A1").Font.Bold = True
        .Columns("A:B").AutoFit
    End With
    
    ' Display Save As dialog to save as template
    Application.DisplayAlerts = False
    ws.Parent.SaveAs Filename:=Environ("APPDATA") & "MicrosoftExcelXLSTARTSheet.xltx", FileFormat:=xlOpenXMLTemplate
    Application.DisplayAlerts = True

    ' Close the new workbook
    ws.Parent.Close SaveChanges:=False
End Sub

Points to Remember

  • The template named `Sheet.xltx` must be saved in the XLSTART folder for Excel to use it as the default for new sheets.
  • Make sure macros are enabled if you’re using VBA code to automate tasks.
  • Saving directly into the XLSTART folder may require administrative privileges depending on your system’s configuration.

Unlock Your Potential

Excel

Basic - Advanced

Access

Access Basic - Advanced

Power BI

Power BI Basic - Advanced

Help us grow the project