Looking for Macro to remove end degree names

JDeMaro22
StarLounger
Posts: 94
Joined: 16 Oct 2021, 16:22

Looking for Macro to remove end degree names

Post by JDeMaro22 »

Hello everyone,

I'm looking for a macro I can run that will remove all doctor degrees from the end of their names in a list. For example removing MD, OD, DO, ARNP etc. I've compiled a list in the Remove tab of all the degrees I would like removed from Column A in "Paste Data Here!". Hopefully this is achievable.

Thank you very much
EileensData.xlsx
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78523
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Looking for Macro to remove end degree names

Post by HansV »

Try this macro:

Code: Select all

Sub RemoveSuffixes()
    Dim wshData As Worksheet
    Dim wshRemove As Worksheet
    Dim rngRemove As Range
    Application.ScreenUpdating = False
    Set wshData = Worksheets("Paste Data Here!")
    Set wshRemove = Worksheets("Remove")
    With wshRemove
        For Each rngRemove In .Range(.Range("A2"), .Range("A1").End(xlDown))
            wshData.Range("A:A").Replace What:=" " & rngRemove.Value, _
                Replacement:="", LookAt:=xlPart, MatchCase:=True
        Next rngRemove
    End With
    Application.ScreenUpdating = True
End Sub
Best wishes,
Hans

JDeMaro22
StarLounger
Posts: 94
Joined: 16 Oct 2021, 16:22

Re: Looking for Macro to remove end degree names

Post by JDeMaro22 »

Amazing, thank you Hans