Forum Discussion
Auto creation of new sheet in a duplicate workbook when created one in original Workbook.
I have designed one excel file,
according to my work requirement,
where I have to add,
another new sheet
twice every week.
There are some formulas, I use for my comfort.
Now, I want that newly created sheet,
to be created automatically
to the connected next excel file
(only sheet but not the contents)
where I will pull certain range of data
from an original sheet (in a designed format)
and analyze data accordingly.
It can be done manually
and I have tried it
(one sheet at a time).
But I want it to happen automatically
in a predesigned format
by automatically creating a new sheet
in a connected duplicate excel file
when new sheet is created in an original file
and display the result as predesigned format.
How I can do it ?
2 Replies
- NikolinoDEPlatinum Contributor
To achieve automatic creation of a new sheet in a duplicate workbook when a new sheet is created in the original workbook, you can use VBA (Visual Basic for Applications) in Excel. VBA allows you to automate tasks and create custom functions. Here's a step-by-step guide:
1. Open the Original Workbook:
Open the Excel workbook where you want to automatically create a new sheet in the duplicate workbook.
2.Enable Developer Tab:
If you haven't enabled the Developer tab, go to "File" -> "Options" -> "Customize Ribbon," and check the "Developer" option.
3. Access the Visual Basic for Applications (VBA) Editor:
Click on the "Developer" tab, and then click on "Visual Basic" to open the VBA Editor.
4. Insert a Module:
In the VBA Editor, right-click on any item in the "Project Explorer" on the left, choose "Insert," and then click "Module."
5. Write VBA Code:
In the module, paste the following VBA code:
Vba code is untested.
Private Sub Workbook_SheetAdded(ByVal Sh As Object) Dim newSheet As Worksheet Dim duplicateWorkbook As Workbook Dim originalSheet As Worksheet ' Set the original sheet and workbook Set originalSheet = ThisWorkbook.Sheets(Sh.Name) Set duplicateWorkbook = Workbooks.Open("C:\Path\To\Your\DuplicateWorkbook.xlsx") ' Change the path accordingly ' Copy the original sheet to the duplicate workbook originalSheet.Copy Before:=duplicateWorkbook.Sheets(1) ' Close the duplicate workbook without saving changes duplicateWorkbook.Close SaveChanges:=False End Sub- Update the path in Workbooks.Open to the path of your duplicate workbook.
6. Save and Close VBA Editor:
Save your workbook and close the VBA Editor.
Now, every time you add a new sheet in the original workbook, this VBA code will automatically create a copy of the new sheet in the specified duplicate workbook. Adjust the code and paths according to your requirements.
Remember to save your workbooks before running or testing any VBA code, as it cannot be undone once executed. The text and steps were edited with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and Like it!
This will help all forum participants.
- Aum_KarCopper ContributorI tried the way you suggested but it didn't work in my context. Thank you for your best try.