Avatar of finnstone
finnstone
 asked on

get the ALL CAPITAL words from a cell

i have 15,000 rows, need a formula for each cell to get the last name.

examples

Mohammed Muftah AL MUFTAH
Loay Jassem Mohammed Abdulmohsin AL KHARAFI
Salim bin Mustahil bin Ahmed bin Ali bin Tamman AL MASHANI


How do I get AL MUFTAH, AL KHARAFI, AL MASHANI

?

Thanks!
Microsoft OfficeMicrosoft ExcelVB Script

Avatar of undefined
Last Comment
Shums Faruk

8/22/2022 - Mon
Martin Liss

Do the last names always start with "AL"?
ASKER CERTIFIED SOLUTION
Shums Faruk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
finnstone

ASKER
thx!
Shums Faruk

As you are talking about 15000 rows, then copy paste below code in module:
Function UpperWords(str As Variant) As String
    Dim i As Integer, sTemp As String, StrTmp As String
    For i = 0 To UBound(Split(str, " "))
        StrTmp = Split(str, " ")(i)
        If UCase(StrTmp) = StrTmp Then sTemp = sTemp & " " & StrTmp
    Next i
    UpperWords = Trim(sTemp)
End Function
Sub ExtractCapitalWords()
Dim Ws As Worksheet
Dim LR As Long
With Application
    .ScreenUpdating = False
    .DisplayStatusBar = True
    .StatusBar = "!!! Please Be Patient...Updating Records !!!"
    .EnableEvents = False
    .Calculation = xlManual
End With
Set Ws = ActiveSheet
LR = Ws.Range("A" & Rows.Count).End(xlUp).Row
Ws.Range("B1:B" & LR).FormulaR1C1 = "=UpperWords(RC1)"
Ws.Range("B1:B" & LR).Value = Ws.Range("B1:B" & LR).Value
Ws.Range("B1").Select
With Application
    .ScreenUpdating = True
    .DisplayStatusBar = True
    .StatusBar = False
    .EnableEvents = True
    .Calculation = xlAutomatic
End With
End Sub

Open in new window

Assuming your data starts from A1 and you want your result in/from B1, Run ExtractCapitalWords
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23