Click the tab of the worksheet that you want to delete. Choose Home→Delete→Delete Sheet on the Ribbon, press Alt+HDS, or right-click the tab and choose Delete from its shortcut menu.
Contents
- 1 How do I delete an entire workbook in Excel?
- 2 Why won’t Excel let me delete a worksheet?
- 3 How do you delete a workbook in Excel on a Mac?
- 4 How do I delete a worksheet in Excel 2007?
- 5 Why can’t I Unshare an Excel workbook?
- 6 Can all the worksheet be deleted in a workbook?
- 7 Why can’t I delete a file?
- 8 How do I delete multiple files on my laptop?
- 9 How do I delete a file?
- 10 How do I delete multiple tabs in Excel on a Mac?
- 11 What is workbook in Microsoft Excel?
- 12 How do u right click on a Macbook?
- 13 What is the shortcut key to delete?
- 14 How do I delete multiple tabs in Excel?
- 15 What is the shortcut to delete multiple rows in Excel?
- 16 How do you delete a workbook in Excel 2013?
- 17 How do I delete a tab in Excel without right clicking?
- 18 How do you delete a sheet in Excel without a mouse?
- 19 How do I delete Unshare Excel workbook?
- 20 How do you edit multiple users in Excel?
How do I delete an entire workbook in Excel?
Delete a worksheet
- Right-click the Sheet tab and select. Delete.
- Or, select the sheet, and then select Home > Delete > Delete Sheet.
Why won’t Excel let me delete a worksheet?
You cannot delete a worksheet from a workbook if that workbook is being shared. You can remove the active worksheet by selecting (Edit > Delete Sheet). You can quickly insert a new worksheet before the active sheet by using the shortcut key (Shift + F11).
How do you delete a workbook in Excel on a Mac?
To delete a sheet, simply right-click on the name of the sheet that you wish to delete. In this example, we want to delete Sheet1. Then select Delete from the popup menu. A message will pop up asking you to confirm the deletion of the sheet.
How do I delete a worksheet in Excel 2007?
To delete a sheet, simply right-click on the name of the sheet that you wish to delete. In this example, we want to delete Sheet1. Then select Delete from the popup menu. A message will pop up asking you to confirm the deletion of the sheet.
Why can’t I Unshare an Excel workbook?
If the box is uncheckable (grayed out), most likely shared workbook protection is on. To unprotect the workbook, click OK to close the Share Workbook dialog box, and then click the Unprotect Shared Workbook button on the Review tab, in the Changes group.
Can all the worksheet be deleted in a workbook?
All the worksheets cannot be deleted in a workbook.
Why can’t I delete a file?
Possible Causes for “Can’t Delete File/Folder” Issue
The file may be used by other programs or system processes.The file or folder is corrupted. You are trying to delete computer system files that are not allowed to delete. The Recycle Bin is corrupted.
How do I delete multiple files on my laptop?
To delete multiple files and/or folders: Select the items you’d like to delete by pressing and holding the Shift or Command key and clicking next to each file/folder name. Press Shift to select everything between the first and last item.
How do I delete a file?
Put a file in trash
- On your Android phone or tablet, open the Google Drive app.
- At the bottom right, tap Files .
- Next to the file you want to delete, tap More. Remove.
How do I delete multiple tabs in Excel on a Mac?
If the sheets are consecutive click the tab of the first sheet to be deleted, hold the Shift Key while you click the tab of the last one to be deleted then use Edit> Delete Sheet & confirm OK.
What is workbook in Microsoft Excel?
A workbook is a file that contains one or more worksheets to help you organize data. You can create a new workbook from a blank workbook or a template. Newer versions Office 2010.
How do u right click on a Macbook?
You can right-click on a Mac computer by using the control button, two-finger tapping your trackpad, or connecting an external mouse to your device. The right-click function on a Mac can be used to bring up menus, copy and paste text, save or delete files, customize your view, and more.
What is the shortcut key to delete?
To delete | Press |
---|---|
Next character | Delete |
Next word | Ctrl+Delete or Ctrl+Backspace |
Previous character | Backspace |
How do I delete multiple tabs in Excel?
If you want to delete multiple sheets and these are non-consecutive/non-adjacent then follow this process:
- Click on the First sheet tab to be deleted.
- Hold the CTRL key.
- Click on the each additional sheet to be deleted.
- Right Click of the mouse on the Sheet Tab.
- Select Delete.
What is the shortcut to delete multiple rows in Excel?
2. Delete multiple Rows using a Shortcut key
- Select the targetted rows from your excel sheet to delete multiple rows in a single attempt.
- Press Ctrl and – keys to delete the selection.
How do you delete a workbook in Excel 2013?
In This Article
- Click the tab of the worksheet that you want to delete.
- Choose Home→Delete→Delete Sheet on the Ribbon, press Alt+HDS, or right-click the tab and choose Delete from its shortcut menu.
How do I delete a tab in Excel without right clicking?
The F4 keyboard shortcut repeats the last command. This shortcut will also apply if you choose to use the right-click deletion method. Note: Microsoft Excel 2010 and 2013 have a new keyboard shortcut for deleting a sheet – ‘Alt’ + ‘H’, ‘D’, ‘S’.
How do you delete a sheet in Excel without a mouse?
How to delete an Excel sheet using a keyboard shortcut – Quora. In Excel 2003, you can select the worksheet tabs you want to delete (if you want to delete multiple worksheets in a workbook, hold the Ctrl key and select them one by oney), then press ALT + E + L keys to delete them.
How do I delete Unshare Excel workbook?
You can turn off sharing by following these steps:
- Display the Review tab of the ribbon.
- Click the Share Workbook tool, in the Changes group. Excel displays the Share Workbook dialog box.
- Clear the Allow Changes check box.
- Click on OK.
How do you edit multiple users in Excel?
Set up a shared workbook
- Click the Review tab.
- Click Share Workbook in the Changes group.
- On the Editing tab, click to select the Allow changes by more than one user at the same time.
- In the Save As dialog box, save the shared workbook on a network location where other users can gain access to it.
VBA Delete Workbook in a folder in Excel. Delete Workbook in Excel VBA. We can delete Excel Workbook using Kill statement or DeleteFile method of file system object(FSO). Find example macros, screenshots and instructions to use macros for your reference in the following chapter. In the following examples before deleting files, check whether files are exists or not.
Table of Contents:
- Objective
- Syntax to Delete Workbook in Excel VBA
- Using Kill Statement Delete Workbook in Excel VBA
- Using FSO: DeleteFile method to Delete Workbook in Excel VBA
- Instructions to Run VBA Macro Code
- Other Useful Resources
Syntax to Delete Workbook in Excel VBA
Let us see the syntax to Delete Workbook in Excel VBA.
Method 1: Here is the first method to delete a Workbook using Kill statement.
Kill(PathName)
Read more details and examples about Kill statement by clicking on the following link.
VBA Kill Function
Method 2: Here is the second method to delete a Workbook using DeleteFile method of File System Object(FSO).
FSO.DeleteFile WorkbookName
Using Kill Statement Delete Workbook in Excel VBA
Let us see the example macro to delete Excel Workbook using VBA Kill function.
'Delete Workbook in Excel VBA using Kill Statement Sub VBA_Delete_Workbook_Excel_Using_Kill() 'Variable declaration Dim sWorkbook As String sWorkbook = "C:SomeswariVBAF1SampleWorkbook.xls" Application.DisplayAlerts = False 'Delete Workbook Kill sWorkbook Application.DisplayAlerts = True MsgBox "Specified Workbook has deleted successfully.", vbCritical, "VBAF1" End Sub
Note: If specified workbook doesn’t exists, it displays an error message. I.e Run time error – “File not found” .
Using FSO: DeleteFile method to Delete Workbook in Excel VBA
Let us see the example macro to delete Excel Workbook using VBA DeleteFile method of File System Object(FSO). Here first we are checking whether file exists or not before deleting. If file exists, then deletes the specified file. Otherwise it displays message.
'Delete Workbook in Excel VBA using DeleteFile method of FSO Sub VBA_Delete_Workbook_Excel_Using_FSO() 'Variable declaration Dim FSO Dim sWorkbookName As String 'File Name to delete sWorkbookName = "C:SomeswariVBAF1SampleWorkbook.xls" 'Set Object for file system object Set FSO = CreateObject("Scripting.FileSystemObject") 'Before deleting check file exists or not If FSO.FileExists(sWorkbookName) Then 'If file exists, It will delete the file from source location FSO.DeleteFile sWorkbookName, True MsgBox "Workbook has deleted successfully.", vbInformation, "VBAF1" Else 'If file does not exists, It will display following message MsgBox "Specified Workbook was not found", vbInformation, "Not Found!" End If End Sub
Output: You can notice specified Workbook has deleted from the specified folder.
Instructions to Run VBA Macro Code or Procedure:
You can refer the following link for the step by step instructions.
Instructions to run VBA Macro Code
Other Useful Resources:
Click on the following links of the useful resources. These helps to learn and gain more knowledge.
VBA Tutorial VBA Functions List VBA Arrays in Excel Blog
VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers
Excel workbooks can contain a large number of different worksheets. Combining all your worksheets in one workbook makes it easy to navigate between them, making data referencing easy and fast. Despite this, certain times while working with Excel worksheets, it reaches a time when you no longer need the data in individual worksheets. The only option remaining is to delete these sheets. Doing this helps in reducing your file size, and you can keep only data that is relevant.
So, to find out how you can delete your irrelevant sheets in excel, read below.
How to delete an Excel worksheet by Right-clicking
1. From the start button on your PC, access Microsoft Office Suite and click on the Microsoft Excel program.
2. Open the workbook file that contains sheets to delete.
3. At the bottom of the workbook, select the worksheet that you want to delete.
4. Right-click on the sheet name and a drop-down menu will be displayed.
5. Select the Delete option. A warning dialogue box pops up asking whether you want to continue the deleting process. Click the Delete tab. After deleting, your sheet will be removed permanently from your workbook.
Using the keyboard shortcut to delete a worksheet
1. From the start button on your keyboard’s PC, access Microsoft Office Suite and click on the Microsoft Excel program.
2. From the File tab, click on the Open option. It will direct you to your documents folder on your PC. From here, select the Excel file that contains the sheet you want to delete.
3. At the bottom of the workbook, select the worksheet that you want to delete.
4. On your keyboard, press the Alt+H+D+S keys. You can also press the Alt+E on your keyboard, then press L. After this, hit Enter. Your sheet will be removed from the workbook. Or you can decide to click on the delete dialogue box that would appear on your screen.
Deleting by Format option
1. At the bottom of your opened workbook, select the worksheet you want to delete.
2. From the main menu’s ribbon, go to the Home tab.
3. Under the group name ‘Cells’ found at the top of the window, select the Delete drop-down arrow. From the given menu list, click Delete Sheet.
4. After you have selected the Delete Sheet Option, you will get a warning dialogue box asking whether you want your sheet deleted permanently. Click on the Delete button.
5. When you go back to your workbook, the deleted sheet will not be available.
Note that;
You can also delete multiple worksheets from a workbook. Below are the steps you have to follow;
- Select the sheets you want to delete. Do this by using the Shift and Ctrl keys.
- Right-click, and from the drop-down menu, select Delete. Apart from this method, you can follow the above steps, and still, you will manage to delete all the selected sheets.
Conclusion
We have given you different ways of deleting Microsoft Excel worksheets from a workbook from the guide above. As long as you are a consistent user of excel or even a new user, deleting a sheet will not be a daunting problem while using the above steps. I hope the article is informative and useful.
Home / VBA / VBA Delete Workbook (Excel File)
To delete an Excel file from a folder you can use two different methods. The first method is the “Kill” statement which takes the file path to refer to the file that you wish to delete. The second method is the FileSystemObject object which has a method associated with it to delete a file.
To use these codes, go to the VBE (Code Editor) from the developer tab.
Delete a File using VBA (Kill Function)
Kill function helps you to delete a single file or multiple files, and use wildcard characters to delete more than one file. Below is the one-line code that deletes the file from the folder that I have on the desktop.
Kill "C:UsersDellDesktopSample Datafile-one.xlsx"
This code will show you an error if the workbook that you specified to delete doesn’t exist.
Helpful Links: Run a Macro – Macro Recorder – Visual Basic Editor – Personal Macro Workbook
Delete All the Files from a Folder using VBA
And if you want to delete all the files that you have in a folder, you can use a wildcard character.
Kill "C:UsersDellDesktopSample Data*.xl*"
Delete a File using the FileSystemObject (Object)
The file system object provides you with access to the computer’s file system. You can learn about it from here, but now, let’s write a code to remove a file.
Full Code
Sub vba_delete_file()
Dim FSO
Dim myFile As String
Set FSO = CreateObject("Scripting.FileSystemObject")
myFile = "C:UsersDellDesktopSample Datafile1.xlsx"
FSO.DeleteFile myFile, True
End Sub
Let’s say you need to write a code that can check for a file, (exists or not) and then delete it. Here’s the code that you need.
Sub vba_delete_file()
Dim FSO
Dim myFile As String
Set FSO = CreateObject("Scripting.FileSystemObject")
myFile = "C:UsersDellDesktopSample Datafile1.xlsx"
If FSO.FileExists(myFile) Then
FSO.DeleteFile myFile, True
MsgBox "Deleted"
Else
MsgBox "There's no workbook with this name."
End If
End Sub
More on VBA Workbooks
VBA Save Workbook | VBA Close Workbook | VBA ThisWorkbook | VBA Rename Workbook | VBA Activate Workbook | VBA Combine Workbook | VBA Protect Workbook (Unprotect) | VBA Check IF a Workbook is Open | VBA Open Workbook | VBA Check IF an Excel Workbook Exists in a Folder| VBA Create New Workbook (Excel File)
- VBA Workbook
When working with Excel, you spend most of your time on the worksheet (which is the area that has all the cells and everything that happens there).
Working efficiently with Excel also means that you have to work with multiple worksheets within the same workbook.
Excel allows you easily add multiple worksheets in the workbook, at the same time you can also easily delete these worksheets.
In this Excel tutorial, I will show you how to quickly delete worksheets in Excel. I would cover multiple methods such as using keyboard shortcuts, options in the ribbon, and VBA to delete sheets in Excel.
Note: In this tutorial, I’m going to use the words ‘sheet’ and ‘worksheet’ interchangeably. But to tell you the difference, Sheets would include Worksheets as well as Chart Sheets, but since Chart Sheets are not that commonly used, whenever I use the word Sheet consider it as a Worksheet.
Delete Sheets Using Right-Click Options
The easiest way to delete a worksheet in Excel is by using this simple two-click mouse technique.
Suppose, you have a worksheet that has three sheets as shown below, and you want to delete Sheet1.
Below are the steps to do this:
- Right-click on the sheet that you want to delete
- Click on the delete option
- In the prompt that shows up, click on the Delete button
You can also use the above technique on sheets that are not even the active sheet. For example, if I’m currently on Sheet1 and I want to delete Shee3, then I can simply right-click on Sheet3 and delete it.
You can also use the same technique to delete multiple sheets at once.
For example, if I want to delete Sheet2 and Sheet3 in one go, I can hold the control key and click on Sheet2 and Sheet3 one by one (while still holding the control key).
By holding the control key, Excel would allow me to select multiple sheets at one go. Once I’m done selecting the desired sheets, I can leave the control key. now I can right-click on any of the selected sheets tabs, and click on delete.
Remember that you cannot delete all the worksheets in a workbook in Excel. there always needs to be at least one sheet in the workbook. if you try and delete all the worksheets (or the only active sheet), you’ll see a prompt that will tell you that you’re not allowed to do this
Keyboard Shortcuts to Delete the WorkSheets
There is not one but two-and-half keyboard shortcuts that you can use to delete worksheets in Excel.
I say two and a half because one of the shortcuts he uses the mouse as well as the keyboard (and is still a faster way to do it)
Hybrid Keyboard Shortcut to Delete Sheet
Right-Click + D
To delete the selected worksheet or worksheets, right-click and then press the D key on your keyboard.
Personally, I find this a lot faster than just using the mouse to delete a worksheet (as I covered in the above section)
Regular Keyboard Shortcut to Delete Sheet
ALT + H + D + S
If you would rather prefer to ditch the mouse and only use the keyboard, the above keyboard shortcut will delete the active sheet or the selected sheets.
You need to press these keys in succession (i.e., one after the other)
While it may look like a slightly longer keyboard shortcut, once you get used to it it’s just as fast as any other technique covered in this tutorial
Legacy Keyboard Shortcut to Delete Worksheets
Like everyone else, Excel also has a past, and it’s not that pretty. I’m talking about the pre-ribbon style era.
For compatibility reasons, Excel still allows some of those old keyboard shortcuts to work in the newer versions. and in many cases, those earlier shortcuts are shorter and better.
Luckily, there is a legacy keyboard shortcut that works to delete worksheets in Excel
ALT + E + L
Deleting the ActiveSheet Using VBA
When it comes to deleting one sheet, or a couple of worksheets, it’s better to use the above-mentioned methods.
While VBA can automate the process, it’s usefulness comes in when you have to repeat the task multiple times.
As you will see, with VBA you can do a lot more when it comes to deleting worksheets in Excel.
So I’ll take you to more advanced use cases, but before that let’s see how to simply delete the active worksheet using VBA.
Below is the VBA code that will delete the active sheet:
Sub DeleteSheet() ActiveSheet.Delete End Sub
If you’re using it in the immediate window, you can simply use the below line:
ActiveSheet.Delete
When you use the above code to delete the active sheet, Excel would show you a prompt where you would have to click the delete button to confirm the action.
Deleting the Sheet Without Showing the Confirmation Prompt
The confirmation prompt message box is a useful feature that makes sure that you have a chance to cancel the deletion of the sheet in case you have run the code accidentally/erroneously
But if you already know what you’re doing, getting this prompt can be quite irritating.
so here is the VBA code that would make sure that the sheets are deleted but you do not see any confirmation prompt message box.
Sub DeleteSheet() Application.DisplayAlerts = False ActiveSheet.Delete Application.DisplayAlerts = True End Sub
In the above code, I have set the Application.DisplayAlerts property to false, which means that Excel will not show you any display alerts while the code is running.
It’s also really important to make sure that you turn it back to true at the end of the code to restore the functionality (as you can see I have done in the above code).
Caution: When you set the Application.DisplayAlerts property to false, Excel would simply delete the worksheet and there would be no way to recover it. so I advise you make a backup copy before you use this kind of code.
Deleting Sheet By Name (If It Exists) Using VBA
VBA allows you to automate the process of deleting a specific worksheet (on multiple worksheets) based on the sheet name.
For example, if you have a worksheet with the name ‘Sales’, you can use the below code to delete it:
Sub DeleteSheetByName() Sheets("Sales").Delete End Sub
This code would only delete the sheet that has the name Sales.
It’s useful when you have a workbook with a lot of sheets and you don’t want to sift through all the worksheets find the one with the name sales and delete it manually.
With the above code, it does not matter how many worksheets there are in the workbook it would simply delete the sales worksheet.
And since I have not changed the Application.DisplayAlert property, you will see a prompt where you would have to click the delete button to confirm the duration of the sales sheet.
In case you want to delete multiple sheets based on their name, you can do that as well.
For example, the below code would delete the sheets with the name Sales, Marketing, Finance:
Sub DeleteSheetsByName() Sheets("Sales").Delete Sheets("Marketing").Delete Sheets("Finance").Delete End Sub
Deleting All Sheets Except the Active Sheet Using VBA
If you have a workbook with multiple worksheets in it, and you want to delete all the worksheets except the active sheet, VBA is probably one of the better methods to do this.
Below is the VBA code that would delete all the sheets except the active sheet in the workbook.
Sub DeleteSheetByName() Dim ws As Worksheet Application.DisplayAlerts = False For Each ws In Sheets If ws.Name <> ActiveSheet.Name Then ws.Delete End If Next ws Application.DisplayAlerts = True End Sub
Note that I have said the Application.DisplayAlerts property to falls at the beginning of the code, as I don’t want to see a prompt for every sheet that is deleted.
Delete All Sheets with a Specific Text String in the Name
This is a slightly more advanced use case of using VBA effectively when deleting worksheets.
Suppose you have a workbook with many different worksheets and you want to delete all the worksheets that have a specific text string in them then you can easily do that using VBA.
For example, below I have a workbook where I want to delete all the worksheets that have the text string “Sales” in them.
Below is the VBA code that would do that:
Sub DeleteSheetByName() Dim ws As Worksheet Application.DisplayAlerts = False For Each ws In Sheets If ws.Name Like "*" & "Sales" & "*" Then MsgBox ws.Name ws.Delete End If Next ws Application.DisplayAlerts = True End Sub
The above code uses the if-then statement to go through all the worksheets in the workbook. It checks the name of all these worksheets and if the name contains the word “Sales”, then that worksheet is deleted.
If you want to change the code and look for any other text string, you can change that in the fifth line of the above code.
Also note that I’ve used an asterisk (*), which is a wild card character, on both sides of the text string that we are looking for in the worksheet name. This ensures that no matter where the string appears in the name of the worksheet, it would still be deleted.
You can also modify the code to make sure that only those worksheets are deleted where the text string appears at the beginning of the worksheet name.
For example, if you want to delete those sheets where the term sales appear at the beginning, use the following code in the fifth line.
If ws.Name Like "*" & "Sales" & "*" Then
Here, I’ve used the wild card character only after the text drink and not before it. This will make sure at while checking the names of the worksheet, only those would satisfy the criteria where the term ‘Sales’ is at the beginning of the name.
So these are some of the methods that you can use when you want to delete sheets in Excel. In most cases, you can easily do this right within the worksheet by using the mouse or the keyboard shortcut.
But in case you have a heavy workbook with a lot of worksheets and you want to quickly delete specific kinds of sheets then you can also use VBA.
I hope you found this tutorial useful.
Other Excel tutorials you may also like:
- How to Delete All Hidden Rows and Columns in Excel
- How to Insert / Delete Comments in Excel (including Shortcuts)
- How to Delete Entire Row in Excel Using VBA
- How to Delete Every Other Row in Excel (or Every Nth Row)
- Delete Blank Rows in Excel (with and without VBA)
- How to Insert New Worksheet in Excel (Easy Shortcuts)
- Excel Tabs/Sheets Not Showing – How to Fix?
Clear and Delete Recent Documents / Workbooks / Presentations List in Office 2007 / 2010 / 2013 / 2016 (Word, Excel, PowerPoint)
Beginning from Microsoft Office 2007, Word, Excel and PowerPoint uses new Office Fluent Ribbon user interface with a big right pane section of the Office or “File” menu been devoted to “Recent Documents”, “Recent Workbooks” or “Recent Presentations” list. The recent files list records each and every files that user opens recently, and display the list whenever Office button or “File” menu is pressed for quick easy access.
Since Office 2013 and Office 2016, Office apps also display “Recent” list which shows all recently opened files upon launching of Office apps such as Word, Excel and PowerPoint.
The “Recent Documents”, “Recent Workbooks” or “Recent Presentations” list in Word, Excel or PowerPoint shouldn’t be any problem if you’re the only user on the computer. However, if the same computer and same user account is shared by many people, or you’re using a borrowed or public computer, the recent files list will expose documents using trace. To protect your privacy, users need to delete all file opened history in “Recent Documents”, “Recent Workbooks” or “Recent Presentations”.
How to Clear and Delete Entire Recent Documents / Recent Workbooks / Recent Presentations List
- Click or tap on Office button or File menu, and then click on Word Options (in Microsoft Word) or Excel Options (in Microsoft Excel) or PowerPoint Options (in Microsoft PowerPoint) in the bottom of Office Menu.
In Office 2013 or Office 2016 or Office 365, go to Options.
- Go to the Advanced tab.
- Scroll down to the Display section.
- Set the value for Show this number of Recent Documents: (for Microsoft Word) to 0 (zero).
- Click OK button.
- Repeat steps above again, and set back the value for the number of Recent Documents to show to its original default, i.e. 17. If you don’t want this particular Office application to remember any Recent Documents, you can leave the value at 0 and skip this step.
How to Delete and Remove Individual Recent Files Entry
And if you not intend to delete all entries in “Recent Documents”, “Recent Workbooks” or “Recent Presentations” list, it’s also possible to right click on a recent file and select Remove from list to delete the entry from the recent files list.
In Office 2007 and Office 2010, uses the following registry trick instead. The trick can also be used if you don’t want to perform the task to clear the recent files list one by one on many Office products, it’s possible to clear and delete the “Recent Documents”, “Recent Workbooks”, “Recent Presentations”, items, all or some of them, in the registry.
To do so, run Registry Editor (regedit.exe) and navigate to the one of the following registry key branches:
HKEY_CURRENT_USERSoftwareMicrosoftOffice12.0WordFile MRU
HKEY_CURRENT_USERSoftwareMicrosoftOffice12.0ExcelFile MRU
HKEY_CURRENT_USERSoftwareMicrosoftOffice12.0PowerPointFile MRU
Note: Change the version of Office in the registry key above based on version number as follow:
- Office 2007: 12.0
- Office 2010: 14.0
- Office 2013: 15.0
- Office 2016: 16.0
Each registry key represent a corresponding Office product respectively, which should be pretty obviously. Inside the File MRU key, there are plenty of items on the right value pane. Delete any – one, some or all – of the item entries that you want to make disappear and delete from “Recent Documents” list. Restart respective Office 2007 program to see the changes.
About the Author: LK
Page load link
I have a macros that generates a number of workbooks. I would like the macros, at the start of the run, to check if the file contains 2 spreadsheets, and delete them if they exist.
The code I tried was:
If Sheet.Name = "ID Sheet" Then
Application.DisplayAlerts = False
Sheet.Delete
Application.DisplayAlerts = True
End If
If Sheet.Name = "Summary" Then
Application.DisplayAlerts = False
Sheet.Delete
Application.DisplayAlerts = True
End If
This code is returning an error:
run time error #424, object required.
I probably have the wrong formatting, but if there is an easier way to do this, it would be very useful.
shA.t
16.4k5 gold badges53 silver badges111 bronze badges
asked Jul 17, 2015 at 11:59
1
Consider:
Sub SheetKiller()
Dim s As Worksheet, t As String
Dim i As Long, K As Long
K = Sheets.Count
For i = K To 1 Step -1
t = Sheets(i).Name
If t = "ID Sheet" Or t = "Summary" Then
Application.DisplayAlerts = False
Sheets(i).Delete
Application.DisplayAlerts = True
End If
Next i
End Sub
NOTE:
Because we are deleting, we run the loop backwards.
answered Jul 17, 2015 at 12:08
Gary’s StudentGary’s Student
95.3k9 gold badges58 silver badges98 bronze badges
Try this code:
For Each aSheet In Worksheets
Select Case aSheet.Name
Case "ID Sheet", "Summary"
Application.DisplayAlerts = False
aSheet.Delete
Application.DisplayAlerts = True
End Select
Next aSheet
answered Jul 17, 2015 at 12:07
R.KatnaanR.Katnaan
2,4764 gold badges23 silver badges35 bronze badges
You could use On Error Resume Next
then there is no need to loop through all the sheets in the workbook.
With On Error Resume Next
the errors are not propagated, but are suppressed instead. So here when the sheets does’t exist or when for any reason can’t be deleted, nothing happens. It is like when you would say : delete this sheets, and if it fails I don’t care. Excel is supposed to find the sheet, you will not do any searching.
Note: When the workbook would contain only those two sheets, then only the first sheet will be deleted.
Dim book
Dim sht as Worksheet
set book= Workbooks("SomeBook.xlsx")
On Error Resume Next
Application.DisplayAlerts=False
Set sht = book.Worksheets("ID Sheet")
sht.Delete
Set sht = book.Worksheets("Summary")
sht.Delete
Application.DisplayAlerts=True
On Error GoTo 0
answered Jul 17, 2015 at 12:24
Daniel DušekDaniel Dušek
13.6k5 gold badges35 silver badges51 bronze badges
5
Worksheets("Sheet1").Delete
Worksheets("Sheet2").Delete
maazza
6,92615 gold badges61 silver badges95 bronze badges
answered Feb 2, 2017 at 16:43
try this within your if statements:
Application.DisplayAlerts = False
Worksheets(“Sheetname”).Delete
Application.DisplayAlerts = True
answered Jul 17, 2015 at 12:04
LuuklagLuuklag
3,90711 gold badges39 silver badges57 bronze badges
4
Updated: 03/12/2022 by
In Microsoft Excel, you can add one or more worksheets to a workbook file. You can also rename, copy, move, and delete a worksheet. To perform any of these actions, follow the steps on this page.
How to add a new worksheet
To add a new worksheet to your Excel file, follow the steps below for the version of Excel on your computer.
Excel 2013 and later
- At the bottom of the Excel window, to the right of the last worksheet listed, click the + symbol.
- A new worksheet is created, with a default name of «Sheet» plus a number. The number used is one more than the number of existing worksheets. For example, if there are three worksheets in the Excel file, the new worksheet is named «Sheet4».
Tip
You can also use the keyboard shortcut Alt+Shift+F1 to create a new worksheet tab in Excel.
Excel 2010 and earlier
- At the bottom of the Excel window, to the right of the last worksheet listed, click the small tab with a folder-like icon.
- A new worksheet is created, with a default name of «Sheet» plus a number. The number used is one more than the number of existing worksheets. For example, if there are three worksheets in the Excel file, the new worksheet is named «Sheet4».
How to rename a worksheet
To rename a worksheet in an Excel file, follow the steps below.
- At the bottom of the Excel window, right-click the worksheet tab you want to rename.
- Click the Rename option.
- Type in the new name for the worksheet and press Enter.
Note
There is a 31 character limit for a worksheet name.
How to copy a worksheet
To copy a worksheet, copying all contents of that worksheet to a new worksheet, follow the steps below.
- At the bottom of the Excel window, right-click the worksheet tab you want to copy.
- Click the Move or Copy option.
- In the Move or Copy window, in the Before sheet section, select the worksheet where you want to place the copied worksheet.
- Check the box for the Create a copy option, then click OK.
A copy of the worksheet is added and placed before the worksheet you selected in step 3 above. For example, if you had two worksheets named «Sheet1» and «Sheet2,» and you selected Sheet2 in step 3, a copy of Sheet2 would be placed before the Sheet1. The result would look like the example picture below. The worksheet named «Sheet2 (2)» is the copy of Sheet2.
- For additional details about how to copy worksheets and workbooks, see: How to copy an entire worksheet in Excel.
How to move or change the order of worksheets
If you want to change the order or move worksheets in your workbook, click-and-drag any worksheet into the order you want it placed. For example, to make the first tab the last tab, click it, and while continuing to hold the button down, drag it after the far-right tab.
How to delete a worksheet from a workbook
- In the sheet tab listing, right-click the worksheet you want to delete.
- From the right-click menu that appears, click the Delete option.
New Microsoft Excel files often contain a couple of blank tabs where you can add data.
But if you only need one tab for your current project, then you may want to get rid of the other ones to avoid confusion.
Fortunately, you can learn how to delete a sheet in Excel and get rid of any of the worksheets in your workbook that you don’t need anymore, even ones that contain data.
How to Delete a Worksheet in Microsoft Excel
- Open the Excel file.
- Select the worksheet tab to delete at the bottom of the window.
- Right-click the selected tab, then choose the Delete option.
In the section below we will show you another method for how to delete a sheet in Excel, including pictures of these steps.
An Excel workbook can consist of a large number of individual worksheets that can be used independently of one another. It is much easier to navigate between multiple sheets in one workbook, plus it allows you to easily reference data in those other worksheets with formulas.
But if you have extra worksheets in one of your workbooks that contain data that you no longer need, you may decide that it is a good idea to delete that sheet. This can be accomplished almost as easily as deleting any other piece of data in an Excel workbook, so continue reading below to learn how to delete a sheet in Excel 2010.
How to Delete an Entire Excel 2010 Worksheet (Guide with Pictures)
The tutorial below is going to delete an entire worksheet from your Excel 2010 workbook. If other sheets in your workbook include references to cells in the sheet that you are deleting, those formulas will not work correctly. Additionally, that worksheet will be deleted permanently. You will not be able to recover data from the worksheet once it has been deleted.
Step 1: Open the Excel workbook containing the sheet that you want to delete.
Step 2: Click the tab at the bottom of the window for the worksheet that you want to delete.
In this example, I am going to be deleting Sheet2.
Step 3: Click the Home tab at the top of the window.
Step 4: Click the arrow under the Delete button in the Cells section of the ribbon at the top of the window, then click the Delete Sheet button.
Step 5: Click the Delete button to confirm that you want to delete the sheet.
Alternatively, you can right-click the sheet tab that you want to delete, then click the Delete option.
Now that you know how to delete a sheet in Excel you will be able to get rid of the worksheets that don’t contain any information, or the sheets that you no longer need to include in your workbook.
More Information on Removing Worksheets in Microsoft Excel
When you right-click on one of the worksheets that you wish to delete from Excel, you are going to see a handful of other actions that you can perform on that sheet. These include things like:
- Insert
- Delete
- Rename
- Move or Copy
- View Code
- Protect Sheet
- Tab Color
- Hide
- Unhide
- Select All Sheets
While our specific task in this article is focused on how to delete a sheet in Excel, it’s helpful to be aware of these options, as they can be handy in other situations, too.
Frequently Asked Questions About Getting Rid of Sheets from an Excel Workbook
How do I delete multiple sheets in Excel?
If you want to delete worksheets from your file, then the process is only slightly different than what you had to do to remove single worksheets in Excel.
You can delete multiple worksheets by holding down the Ctrl key on your keyboard, then selecting all the sheets that you would like to remove. You can also hold down the Shift key as you click two different sheets and it will also select all of the sheets between the two selected sheets.
Once they are all selected, simply right-click on one of the selected worksheets, then click Delete or select Delete Sheet from the shortcut menu.
What happens if I delete the active worksheet in Excel?
Whether you are removing one of the worksheets from your file or you are deleting multiple sheets, Excel is going to give you the same prompt regardless of whether the active sheet is included in that selection or not.
That confirmation window or warning dialogue box will say “Microsoft Excel will permanently delete this sheet. Do you want to continue?” if one of the sheets that you have selected contains data.
If you click the Delete button on the pop up window then it will proceed with deleting worksheets from the workbook.
Is there another way to delete Excel worksheets besides right-click on them?
Yes, you can also complete the deleting process from the Home tab on the worksheet.
Simply click Home at the top of the window, click the Delete button in the Cells group of the ribbon, then choose the delete Sheet option from the drop down menu.
This is another way to easily delete multiple worksheets, as any selected worksheet will also be removed from the workbook when you utilize this option.
If you want to remove a sheet from view, but you do not want to delete the data, you can also learn how to hide a sheet in Excel 2010.
Additional Sources
Matthew Burleigh has been writing tech tutorials since 2008. His writing has appeared on dozens of different websites and been read over 50 million times.
After receiving his Bachelor’s and Master’s degrees in Computer Science he spent several years working in IT management for small businesses. However, he now works full time writing content online and creating websites.
His main writing topics include iPhones, Microsoft Office, Google Apps, Android, and Photoshop, but he has also written about many other tech topics as well.
Read his full bio here.