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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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