REAL-TIME

VBA Projects

Full Access with Source Code
  • Designed and Developed by PNRao

  • Full Access with VBA Source Code

  • Well Commented Codes Lines

  • Creative and Professional Design

Effortlessly
Manage Your Projects

120+ Project Management Templates

Seamlessly manage your projects with our powerful & multi-purpose templates for project management.

120+ PM Templates Includes:
  • 50+ Excel Templates

  • 50+ PowerPoint Templates

  • 25+ Word Templates

Share Post

Delete Worksheet method in VBA is used to delete the sheet from the Excel workbook. When we delete a worksheet, Delete worksheet method displays a dialog box that reminds the user to confirm the deletion by default. If we click on Delete button on the dialog box then it deletes the worksheet from a workbook. It has Boolean value. That means dialog box will appear with two options. That is either Cancel(False) or Delete(True).

VBA Delete Method Excel Worksheet Object

Why we use Delete Worksheet method in VBA?

Sometimes we may don’t want the some of the worksheets in a workbook. We may thought to delete those worksheets. During that time we can use Delete worksheet method to delete the worksheets.

VBA Delete Worksheet Method- Syntax

Here is the example syntax to Delete the Worksheet using VBA.

Worksheets(“YourSheetName”).Delete

Where Worksheet represents Object and Delete is the method of worksheet object.

VBA Delete Worksheet Method: Example 1

Please see the below VBA code to Delete Worksheet from a workbook with warning message. When we are deleting worksheet, it will display Excel dialog message and prompts the confirmation message to the user. Once you click on Delete button no more deleted sheet will be available in a workbook. If you click on cancel button, it won’t delete the Worksheet in a workbook.

Sub Delete_Sheet()
    Sheets("Sheet2").Delete
    ‘Or
    Sheet2.Delete
End Sub

In the above example we have deleted sheet named ‘Sheet2’ from a workbook using Delete method of worksheet object.

VBA Delete Worksheet Method: Example 2

Please see the below VBA code to Delete active Worksheet from a workbook.

Sub Delete_ActiveSheet()
    ActiveSheet.Delete
End Sub

In the above example we have deleted active sheet from a workbook using Delete method of worksheet object.

VBA Delete Worksheet Method: Example 3

Please see the below VBA code to Delete Worksheet from a workbook without any warning message.

Sub Delete_Sheet_WithoutWarningMessage()
    Application.DisplayAlerts = False
    Sheets("Sheet2").Delete
    Application.DisplayAlerts = True
End Sub

In the above example we have deleted Worksheet from a workbook using Delete method of worksheet object. And it will show you how to stop showing warning message while deleting worksheet.

VBA Delete Worksheet Method – Instructions

Please follow the below step by step instructions to execute the above mentioned VBA macros or codes:

  1. Open an Excel Worksheet
  2. Press Alt+F11 to Open the VBA Editor window or Open it from the Developer Tab
  3. Insert a Module from Insert Menu
  4. Copy the above code for activating worksheet and Paste in the code window(VBA Editor)
  5. Save the file as macro enabled Worksheet
  6. Press ‘F5’ to run it or Keep Pressing ‘F8’ to debug the code line by line and then check deleted Worksheet doesnot exist in the Workbook..
Effortlessly Manage Your Projects and Resources
120+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

Save Up to 85% LIMITED TIME OFFER
Project Management Templates

All-in-One Pack
120+ Project Management Templates

Essential Pack
50+ PM Templates

Excel Pack
50+ Excel PM Templates

PowerPoint Pack
50+ Excel PM Templates

MS Word Pack
25+ Word PM Templates

Ultimate Project
Management Template
Ultimate Resource
Management Template
Project Portfolio
Management Templates
Last Updated: March 2, 2023

One Comment

  1. Robert Ochoa July 15, 2019 at 10:27 PM

    Is it possible if I by mistake delete a TAB from my workbook to have a separate VBA code recover deleted TAB form workbook?

Leave A Comment