It works for me
Sub DeleteXSheetInAWorkbok()
Dim DeleteThis$, FilePath$, Curr_File$, FileType$
Dim FldrWkbk As Workbook, wsh As Worksheet
Application.DisplayAlerts = False
DeleteThis = ActiveSheet.Range("A1")
FileType = "*.xlsb*"
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = ThisWorkbook.Path
.AllowMultiSelect = False
If .Show = -1 Then
FilePath = .SelectedItems(1) & "\"
Else
Exit Sub
End If
End With
Curr_File = Dir(FilePath & FileType)
Do Until Curr_File = ""
' Set FldrWkbk = Workbooks.Open(FilePath & Curr_File, False, True)
Set FldrWkbk = Workbooks.Open(Curr_File)
For Each wsh In FldrWkbk.Sheets
If wsh.Name = DeleteThis Then
wsh.Delete
FldrWkbk.Save
Exit For
End If
Next wsh
FldrWkbk.Close
Curr_File = Dir
Loop
Set FldrWkbk = Nothing
Application.DisplayAlerts = True
End Sub
Bookmarks