vba trim phrases in all sheet

I would like a code that would trim a series of phrases in a sheet.
The phrase would be "Domestic Priority".
So, if the phrase was actually "Domestic Priority Letter" - I would like to trim to only "Domestic Priority.
I would do this for all Column A - but don't know which rows.
This is not a list - they are random rows but all rows in Column A.

Thanks!
Euro5Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Again you can modify the headers ion this code.

Sub DeleteThem()
Dim lngLastRow As Long
Dim lngRow As Long
Dim lngEnd As Long
Dim bOK As Boolean
Dim ws As Worksheet

Application.ScreenUpdating = False

For Each ws In Worksheets
    lngLastRow = .Range("A1048576").End(xlUp).Row
    
    For lngRow = lngLastRow To 1 Step -1
        If .Cells(lngRow, 1) = "Domestic First Overnight Non-Freight" Or _
           .Cells(lngRow, 1) = "Continental US Home Delivery" Or _
           .Cells(lngRow, 1) = "Ground - Ground Multiweight Rates" Then
            bOK = False
            For lngEnd = lngRow + 1 To lngLastRow
                ' Look for special ending phrases
                If .Cells(lngEnd, 1) = "Please refer to list rates for this service." Or _
                   .Cells(lngEnd, 1) = "Net Rates are not available for these services" Then
                    Exit For
                End If
                ' Look for a rate table.
                If InStr(1, .Cells(lngEnd, 1), "Weight") > 0 Then
                    ' We found one so quit this search
                    bOK = True
                    Exit For
                End If
            Next
            If Not bOK Then
                Range(.Cells(lngRow, 1), .Cells(lngEnd, 1)).EntireRow.Delete
            End If
        End If
    Next
Next

Application.ScreenUpdating = True
End Sub

Open in new window

0
Euro5Author Commented:
Martin - Does this trim the phrase? It looks exactly like what I have
0
Martin LissOlder than dirtCommented:
It is exactly the same except for line 10 which causes the code to act on all sheets. Lines 14 to 16 may also be different depend on if you added or subtracted any header values.
0
Euro5Author Commented:
I need to to trim the phrase "Domestic Priority" on the one sheet.
0
Martin LissOlder than dirtCommented:
Did you change the question? I was sure it talked about more than one sheet. Anyhow if all that you want to do is to change "Domestic Priority Letter" to "Domestic Priority"?  then

Sub UpdateDomesticPriority()
Dim lngLastRow As Long
Dim lngRow As Long

Application.ScreenUpdating = False

With ActiveSheet
    lngLastRow = .Range("A1048576").End(xlUp).Row
    
    For lngRow = 1 to lngLastRow
        If .Cells(lngRow, 1) = "Domestic Priority Letter" Then
               .Cells(lngRow, 1) = "Domestic Priority"
        End If
    Next

Application.ScreenUpdating = True
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.