So, when you run this code it adds two sheets one is before and one is after the “mySheet”.
Now in the above code, you have two lines of code where you have used before and after an argument in the Sheet.Add method. Add a Sheet After/Before a Specific SheetĪs these arguments are already there in the Sheets.Add where you can specify the sheet to add a new sheet before or after it. In the above code, cell A1 is used to get the name for the new sheet. You can also take the value to use as the sheet’s name from a cell. In the above code, we have used the name object ( LINK) which helps you to specify the name of a sheet. If you want to rename the sheet after adding it, you can use the following code: Sub AddNewSheetswithNameExample1() Now the count of the sheets that you have defined is 5, so when you run this code it instantly adds the five new sheets in the workbook. To add multiple sheets in one go, you just need to define the COUNT argument with the number of sheets you want to add. Sub SheetAddExample2()Īs you are already in the active workbook you can use the below code as well. Here’s one more way to write this, check out the below code. This code tells Excel to add a sheet in the active workbook, but as you don’t have any argument it will use the default values and add one worksheet(xlWorksheet) before the active sheet. To add a single sheet, you can use the below code, where you didn’t specify any argument. Different Ways to Add New Sheets in a Workbook using a VBA Codeīelow you have different ways to add a new sheet in a workbook: 1.