Sometimes you may want to save only one worksheet in one workbook, actually there are two ways to implement this. The first one, you can remove the others from current workbook, you must confirm that these worksheets are useless before removing. The second one, you can copy current worksheet to another new workbook, then only one single worksheet exists in the new workbook. This article will introduce you two ways to save only one single worksheet in one workbook based on above two methods. Please read article below and get the details.
Method 1: Save One Single Worksheet in New Workbook by Move or Copy Function
Create a workbook with some worksheets. See screenshot below.
If we want to save only Test in workbook, we can follow below steps.
Step 1: On sheet Test, right click to load menu. Select ‘Move or Copy’.
Step 2: After above step, Move or Copy dialog pops up. In Move selected sheets section, under To book, select new book in dropdown list. Then click OK.
Step 3: Verify that this time sheet Test is removed and saved in another workbook but workbook name is not changed, and the others are kept in current workbook. The two workbooks have the same name.
Step 4: If you want to keep worksheet Test in original workbook, you can check on option ‘Create a copy’ in Move or Copy dialog, then it will be kept after moving.
Method 2: Save One Single Worksheet and Remove the Others by VBA Code
If we want to keep only current worksheet and removed the others, we can edit VBA code to remove them directly.
Step 1: On current visible worksheet, right click on sheet name tab to load Sheet management menu. Select View Code, Microsoft Visual Basic for Applications window pops up.
Or you can enter Microsoft Visual Basic for Applications window via Developer->Visual Basic. You can also press Alt + F11 keys simultaneously to open it.
Step 2: In Microsoft Visual Basic for Applications window, click Insert->Module, enter below code in Module1:
Sub DeleteSheets1() Dim RemoveWS As Worksheet For Each RemoveWS In Application.ActiveWorkbook.Worksheets If RemoveWS.Name <> "Sheet3" Then RemoveWS.Delete End If Next Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub
In above code, ‘If RemoveWS.Name <> “Sheet3” Then…’ in this script ‘Sheet3’ is the sheet name you want to save in workbook.
Step 3: Save the codes, see screenshot below. And then quit Microsoft Visual Basic for Applications.
Step 4: Press F5 to run macro. Verify that below message pops up.
Step 5: Click Delete on message. Then you will find worksheets except the defined one in script are removed one by one.