troubleshooting Question

vba replace clearing on all sheets

Avatar of Euro5
Euro5Flag for United States of America asked on
Microsoft OfficeMicrosoft ExcelVBA
1 Comment1 Solution10 ViewsLast Modified:
I have this wonderful VBA cold that removes the row when it finds the phrase.
BUT I find that I have a tab that I don't want it to run on, but this code runs through all the worksheets. Is there any way to say "Run on all worksheets EXCEPT this one?"
The tab "Mapping" is the one I need to exclude. THANK YOU!!
Sub ReplaceTotal()

Dim rDelete As Range
Dim strSearch As String
Dim iLookAt As Long
Dim bMatchCase As Boolean
Dim ws As Worksheet


strSearch = "Total"    'Value to search for inbetween ""


iLookAt = xlPart 'Change to xlWhole if the entire cell must equal search string
bMatchCase = False  'Change to True if you want search to be case sensitive


Set rDelete = Nothing


Application.ScreenUpdating = False


For Each ws In Worksheets
With ws.UsedRange
    Set rFind = .Find(strSearch, LookIn:=xlValues, LookAt:=iLookAt, SearchDirection:=xlPrevious, MatchCase:=bMatchCase)
    If Not rFind Is Nothing Then
        Do
            Set rDelete = rFind
            Set rFind = .FindPrevious(rFind)
            If rFind.Address = rDelete.Address Then Set rFind = Nothing
            rDelete.EntireRow.Delete
        Loop While Not rFind Is Nothing
    End If
End With
Next
Application.ScreenUpdating = True
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros