Delete multiple sheets by their name

PankajMaheshwari

New Member
Joined
Sep 7, 2020
Messages
26
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
  3. Mobile
Hi Experts,

I have a workbook which has multiple sheets (around 150 sheets). I also have a list of names of all those sheets. Now what I want to do is delete few sheets (may not be in sequence).

Can I delete sheets by their name? VBA code would be in a way that when I execute it, it asks me a range with sheets name to select. Once I select the range with sheets name, those sheets are deleted.

I tried searching this everywhere but no help. I hope this is even doable.

Thanks for any help.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
This macro will prompt you to select the desired range and then it will delete the selected sheets.
VBA Code:
Sub deleteSheets()
    Application.DisplayAlerts = False
    Dim wsRng As Range, rng As Range
    Set wsRng = Application.InputBox(prompt:="Select Range", Type:=8)
    For Each rng In wsRng
        Sheets(rng.Value).Delete
    Next rng
    Application.DisplayAlerts = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top