ACRONYM

ACRONYM(text, just_capitals)
Returns the first letter of each word.

textThe text you want the acronym for.
just_capitals(Optional) Whether to only use the words that have capital letters.

REMARKS
* The "text" can be a cell range.
* If "just_capitals" is left blank, then False is used.
Columns=1

 A
1=JS.ACRONYM("Microsoft Office Add- ins") = MOA
2=JS.ACRONYM("Rapid Application Development") = RAD
3=JS.ACRONYM("By The Way") = BTW
4=JS.ACRONYM("National Society for the Prevention of Cruelty to Children") = NSFTPOCTC
5=JS.ACRONYM("National Society for the Prevention of Cruelty to Children", TRUE) = NSPCC

1 - What is the acronym of "Microsoft Office Add-ins".
2 - What is the acronym of "Rapid Application Development".
3 - What is the acronym of "By The Way".
4 - What is the acronym of "National Society for the Prevention of Cruelty to Children".
5 - What is the acronym of "National Society for the Prevention of Cruelty to Children" only including capital letters.


Public Function ACRONYM( _ 
         ByVal sText As String, _
Optional ByVal bJustCapitals As Boolean = False) _
         As String

Dim sreturn As String
Dim inextspace As Integer
Dim sfirstcharacter As String
Dim sword As String

    sText = VBA.Trim(sText)
    Do While VBA.Len(sText) > 0
       inextspace = VBA.InStr(1, sText, " ")
       If (inextspace > 0) Then
          sword = VBA.Trim(VBA.Left(sText, inextspace - 1))
          sText = VBA.Right(sText, VBA.Len(sText) - inextspace)
       Else
          sword = sText
          sText = ""
       End If
       
       sfirstcharacter = VBA.Left(sword, 1)
       If (bJustCapitals = True) Then
          If (VBA.Asc(sfirstcharacter) >= 65 And VBA.Asc(sfirstcharacter) <= 90) Then
             sreturn = sreturn & VBA.UCase(sfirstcharacter)
          End If
       End If
       
       If (bJustCapitals = False) Then
          sreturn = sreturn & VBA.UCase(sfirstcharacter)
       End If
    Loop
    ACRONYM = sreturn
End Function

© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext