Hello Mark
I'd use this function that I found somewhere on the net a long time ago
Code:
Private Function SheetExists(sname) As Boolean
' Returns TRUE if sheet exists in the active workbook
Dim x As Object
On Error Resume Next
Set x = ActiveWorkbook.Sheets(sname)
If Err = 0 Then SheetExists = True _
Else SheetExists = False
End Function
then use a macro like this
Code:
Sub DeleteSheetsInColB()
Dim rng As Range 'the range containing sheet names to be deleted
Dim cel As Range 'each individual cell within that range of sheet names
'set the range of sheet names to be deleted
Set rng = Sheets("Sheetlist").Range("B2:B30")
'prevent Excel's warning about deleting sheets
Application.DisplayAlerts = False
'step through the list of sheet names
For Each cel In rng
'check that the cell is not empty
If Len(cel.Value) > 0 Then
'cell contains name of a sheet, check if sheet actually exists
If SheetExists(cel.Value) = True Then
'delete the sheet
Sheets(cel.Value).Delete
End If
End If
Next cel
'turn warnings back on
Application.DisplayAlerts = True
End Sub
Copy both of these codes into a new module and give a try.
Good luck with your project. Hope this is of some assistance.
Bookmarks