• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Delete Several Sheets That They Are In A List

hoomantt

Member
Hi,Dear Professors!
i need a macro code
i have a file with several sheets
i list several of these sheets in a list(in column(A) in a sheet that named("Menu")
i want to delete just sheets that they named in that list in column A in sheet("menu")
perhaps there is a name in the list(in column(A)) that there is not a sheet as this name(excel does not give me error for this)
thanks a lot
Dear Friends
 
Hi Hoomantt

The following should sort you out. It assumes your data is in A2 and it assumes that you are running the code from the Menu sheet.

Code:
Option Explicit
 
Sub DelShts()
Dim i As Integer
Application.DisplayAlerts = False
 
    For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
        On Error Resume Next
        Sheets(Range("A" & i).Value).Delete
    Next i
  On Error GoTo 0
    Application.DisplayAlerts = True
End Sub

I will upload a file to show workings.

Take care

Smallman
 

Attachments

  • DelSheets.xlsm
    26.2 KB · Views: 1
Back
Top