Copy a Hidden Template Sheet with an Excel VBA Macro
Question details
The user needs a VBA macro that copies a hidden template worksheet and hides the template again afterward.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Create a new worksheet from a hidden template within the workbook.
- Observed behavior
- Excel may not copy the template while it is hidden, so it needs to be made visible temporarily.
Make sure the workbook contains a worksheet named Original and at least one other sheet, and that its workbook structure is not protected. Save it as a macro-enabled workbook (.xlsm) and enable macros only if you trust the file.
Temporarily Unhide and Copy the Template with VBA
Use this macro to copy the template before the second sheet and restore its previous visibility.
In Excel, open the workbook and select Developer > Visual Basic. If Developer is not visible, enable it in Excel's ribbon settings.
In the VBA editor, select the workbook, choose Insert > Module, and paste: Sub CopyHiddenTemplate() Dim template As Worksheet Dim originalVisibility As XlSheetVisibility Set template = ThisWorkbook.Worksheets("Original") originalVisibility = template.Visible template.Visible = xlSheetVisible template.Copy Before:=ThisWorkbook.Sheets(2) template.Visible = originalVisibility End Sub
Return to Excel, select Developer > Macros, choose CopyHiddenTemplate, and click Run. A copy of Original appears before the second sheet.

Work with Excel Templates in WPS Spreadsheet
WPS Office is a free, lightweight, easy-to-use Office alternative with a familiar interface. Open compatible Excel workbooks and continue working with their sheets as you move between office suites. It does not fix Excel VBA behavior, and macro support can vary by WPS version.

Frequently Asked Questions
Why does the macro make the template visible before copying it?
Excel may not copy a worksheet while it is hidden. Setting its Visible property to xlSheetVisible before calling Copy avoids that situation.
Will the macro preserve a very hidden template?
Yes. The macro stores the template's original Visible property and restores it after a successful copy, including xlSheetVeryHidden.
How do I change where the copied sheet appears?
Change Before:=ThisWorkbook.Sheets(2) to another destination, such as After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count), to place the copy at the end.
Why does the macro fail when changing sheet visibility?
Check whether the workbook structure is protected. In Excel, go to Review > Protect Workbook and remove structure protection if you have permission, then run the macro again.




