Macro command to delete tabs with "Quote *"

bam

New Member
Joined
Dec 19, 2002
Messages
12
I have a macro that creates up to 8 Excel tabs titled "Quote 1", "Quote 2",..... depending on the options chosen. How do I write the macro command to delete all of the tabs with the word "Quote " in them so that I can rerun the macro and create new quotes?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi,

try:

Code:
Sub Test()
    Dim wksSheet As Worksheet
    For Each wksSheet In ThisWorkbook.Worksheets
        If wksSheet.Name Like "Quote*" Then
            Application.DisplayAlerts = False
            wksSheet.Delete
            Application.DisplayAlerts = True
        End If
    Next wksSheet
End Sub
Case_Germany
 
Upvote 0
Note at least 1 worksheet must be present in a given file at any one time so if you have only QUOTE sheets in your file you must create a non-quote sheet that is not hidden such that all Quote sheets may be deleted without error.

Code:
Sub Delete_Quote_WS()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In ActiveWorkbook.Worksheets
    Select Case InStr(UCase(ws.Name), "QUOTE")
        Case Is > 0
            ws.Delete
    End Select
Next ws
Application.DisplayAlerts = True
End Sub
 
Upvote 0
I "Like" your response. The "Like" command works like a charm. I'll keep the other suggestion handy for other uses.
Have a good one.
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,303
Members
449,078
Latest member
nonnakkong

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top