We help IT Professionals succeed at work.
Get Started

Macro Adjustment to prevent complete deletion

Bright01
Bright01 asked
on
40 Views
Last Modified: 2015-12-16
EE Pros,

I have a great WS that a number of EE Pros have helped me out with.  It now works incredibly well.  However, I can see a potential problem as I add additional Tabs or integrate this WS into a larger WB with existing Tabs.

The macro for deleting all tabs except the original uses a bit of code that may delete ALL TABs other then the original.  So instead of deleting only the "spawned" tabs (i.e. Priority_Map1, Priority_Map(2), etc. etc., I think it would auto. delete ALL TABS except the Priority_Map Tab.  Can you add a little code that will only delete tabs that have "Priority_Map" with an extension?

Thank you,

B.

Here's the code:

Sub Deletesheet()
Application.EnableEvents = False
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Worksheets
Application.DisplayAlerts = False
Select Case sht.Name
        Case "Priority_Map"
            'Do Nothing
        Case Else
            sht.Delete
    End Select
Next
Application.DisplayAlerts = True
  Application.EnableEvents = True
End Sub
Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2016
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE