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 <[email protected]> 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 [email protected]
If you find any spam message in the group, please send an email to:
Ayush Jain @ [email protected] or
Ashish Jain @ [email protected]
-------------------------------------------------------------------------------------
-~----------~----~----~----~------~----~------~--~---