200+ Video Lessons Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.) View Course () Available for: UI for ASP.NET MVC | UI for ASP.NET AJAX | UI for Blazor | UI for WPF | UI for WinForms | UI for Silverlight | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI This article demonstrates how to add, remove and reorder worksheets inside a workbook. Add WorksheetsAdding a new worksheet to a workbook can be easily achieved through its Worksheets collection. The collection exposes an Add() method that does not take arguments and returns the instance of the newly created worksheet. By default worksheets are assigned the first available name in the sequence Sheet1, Sheet2, Sheet3… You can easily change the name of the worksheet through the Worksheet.Name property. More information about renaming a worksheet is available in the Rename a Worksheet article. Example 1 creates a workbook from scratch and adds a single worksheet to it. Since this is the first worksheet in the workbook, it is also set as the active worksheet. All worksheets added after it will not become active. Example 1: Create a workbook and add a worksheet to itWorkbook workbook = new Workbook(); Worksheet newWorksheet = workbook.Worksheets.Add(); The Worksheets collection of the workbook offers two methods for removing worksheets: Remove() and RemoveAt(). The former method requires the worksheet name or the worksheet instance to be passed as an argument. The latter allows you specify the index of the worksheet you would like to remove. Example 2 creates a workbook and adds four worksheets. All worksheets are with their default names: Sheet1, Sheet2, Sheet3 and Sheet4. The code further demonstrates how to remove three worksheets using all of the aforementioned remove methods. Example 2: Add and remove worksheetsWorkbook workbook = new Workbook(); workbook.Worksheets.Add(); // Sheet1 Worksheet secondWorksheet = workbook.Worksheets.Add(); // Sheet2 workbook.Worksheets.Add(); // Sheet3 workbook.Worksheets.Add(); // Sheet4 workbook.Worksheets.RemoveAt(3); // Removed Sheet4 workbook.Worksheets.Remove("Sheet1"); // Removed Sheet1 workbook.Worksheets.Remove(secondWorksheet); // Removed Sheet2 // the only worksheet left is Sheet3 Reorder WorksheetsIf you would like to change the order the worksheets appear inside the workbook, you can use the Move() method of the Sheets collection. The method allows you to move one or more consecutive sheets to a specified position. In Example 3, you can see how you can insert 4 sheets and move the last one to the first position in the collection. When the workbook is visualized, the fourth sheet will be the first one visible in the sheet tabs. Example 3: Add and reorder worksheetsWorkbook workbook = new Workbook(); workbook.Worksheets.Add(); // Sheet1 workbook.Worksheets.Add(); // Sheet2 workbook.Worksheets.Add(); // Sheet3 workbook.Worksheets.Add(); // Sheet4 workbook.Sheets.Move(3, 1, 0); // Move the fourth sheet to the first place
Excel relies on a number of rules for displaying sheets, but you can put them in the order you like with just a few quick clicks. When you add an worksheet, Excel positions it between the currently selected sheet and the previous sheet. Regardless of how careful you are adding new sheets, you might want to rearrange them. To do so, simply right-click the tab you want to move and select Move Or Copy from the resulting context menu. Then, in the Before Sheet dialog box, select the appropriate sheet or select the (Move To End) option. For instance, the sheets in the workbook shown below represent the first three months of the year, but they aren’t in the customary order: January; February; March.
You can use the Move or Copy Sheet command to move or copy entire worksheets (also known as sheets), to other locations in the same or a different workbook. You can use the Cut and Copy commands to move or copy a portion of the data to other worksheets or workbooks.
OR
When you need to reorganize your data, you can easily change the order of sheets in a workbook, or move or copy a sheet to another workbook. But be aware that calculations or charts that are based on sheet data may become inaccurate if you move the sheet.
Caution: When you move a sheet to another workbook, check any formulas or charts that refer to data on the sheet because moving the sheet might cause errors or produce unintended results in your data. Similarly, if you move a sheet that is referred to by 3-D references, the calculation might include or leave out data on the sheet.
Coloring the sheet tabs can help you keep track of your information in a large workbook.
In Excel for the web, you can duplicate (or copy) worksheets within the current workbook. Simply right-click the tab name at the bottom of the sheet and click Duplicate.
Note: You may receive an error when you are trying to duplicate a worksheet that contains a chart, picture, or shape. If you get an error, you can duplicate the sheet manually.
If you have elements in your worksheet that interfere with duplicating it, you can still create a copy of the worksheet manually by copying all the data and pasting it into a new sheet. Here's how:
In Excel for the web, the option to move or copy a sheet isn’t available when you right-click a sheet tab, as it is in the Excel desktop application. In Excel for the web, you can achieve the same result by copying all of the data in the worksheet and pasting it into a blank worksheet in the other workbook. Follow these steps to move or copy a worksheet to another workbook in Excel for the web:
|