not delete worksheets from names in a range
One way:
Sub DelShts()
Dim rng() As Variant
Dim i As Integer
Dim ans As Variant
Application.DisplayAlerts = False
rng = Range("A2:A6")
For i = Sheets.Count To 1 Step -1
On Error Resume Next
ans = Application.WorksheetFunction. _
Match(Sheets(i).Name, rng, 0)
If ans = Empty Then Sheets(i).Delete
ans = Empty
On Error GoTo 0
Next i
Application.DisplayAlerts = True
End Sub
Hope this helps
Rowan
DARREN FONG wrote:
Is there anyway to delete worksheets where one worksheet contains a
range with the names of worksheets I DONT want to delete?
i.e I want to have a code that says "do not delete worksheets in the range
but delete all other worksheets"
|