run macro on selected sheets only
Hallo Amy,
what is your question?
Another posibillity is to set a sheet property:
' Add a property to every sheet that should no be delted:
Call oWks.CustomProperties.Add( "DONT_DELTE", 1)
' Add this code to assure that the user doesnt delete sheets with this
property:
Dim i As Long
Dim bDoNotDelete As Boolean
bDoNotDelete = False
For i = 1 To Sh.CustomProperties.Count
If Sh.CustomProperties(i).Name = "DONT_DELTE" Then
MsgBox "Dont delte this table"
bDoNotDelete = True
End If
Next i
If Not bDoNotDelete Then
Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
End If
Dim i As Long
Dim bDoNotDelete As Boolean
bDoNotDelete = False
For i = 1 To Sh.CustomProperties.Count
If Sh.CustomProperties(i).Name = "DONT_DELTE" Then
MsgBox "Dont delte this table"
bDoNotDelete = True
End If
Next i
If Not bDoNotDelete Then
Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
End If
|