Hi , chk if this works for u
Sub test() On Error Resume Next Application.DisplayAlerts = False Criteria = "No Sales" For i = 1 To Sheets.Count Sheets(i).Select cellf = Cells.Find(what:=Criteria, after:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate If cellf = True Then Sheets(i).Delete Else End If Next Application.DisplayAlerts = True End Sub On Thu, May 28, 2009 at 5:30 AM, sjsean <sjsean95...@gmail.com> wrote: > > I have a set of worksheets where the data provider always puts a sheet > with "No Sales". > > I am trying to write a macro that will remove this sheet (and others > if they fit the above criteria). > > Sub test() > For i = 1 To Sheets.Count > Sheets(i).Select > Cells.Select > Dim r As Range > Set r = Selection.Find(What:="No Sales", After:=ActiveCell, > LookIn:=xlFormulas, _ > LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ > MatchCase:=True).Activate > > If Not r Is Nothing Then Sheets(i).Delete > Next > > > > End Sub > > > > --~--~---------~--~----~------------~-------~--~----~ ------------------------------------------------------------------------------------- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com ------------------------------------------------------------------------------------- -~----------~----~----~----~------~----~------~--~---