if sheets name contrains phrase "example" delete this sheet

pudle

New Member
Joined
Jul 19, 2012
Messages
8
im trying to write a macro to tidy up a workbook with allot of unnecessary sheets, what id like to do is delete all sheets the contain the word/phrase " v " (note spaces either side of the v). Browsing around i found this macro bellow, but it dose the opposite, it keeps all the sheets with " v " and deletes all the others, i just cant figure out how to get it to work the other way

Sorry if this is such an easy question, im pretty new to vba !

Code:
Sub DeleteWS()
For Each ws In Sheets
Application.DisplayAlerts = False
If ws.Name <> " v " Then ws.Delete
Next
Application.DisplayAlerts = True
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Rich (BB code):
Sub DeleteWS()
For Each ws In Sheets
Application.DisplayAlerts = False
If ws.Name = " v " Then ws.Delete
Next
Application.DisplayAlerts = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,205
Members
448,554
Latest member
Gleisner2

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