ACRONYM
ACRONYM(sText, bJustCapitals)
Returns the first letter of each word.
| sText | The text you want the acronym for. |
| bJustCapitals | (Optional) Whether to just use the words that start with a capital letter. |
REMARKS
Public Function ACRONYM( _
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
![]() |
For instructions on how to add this function to a workbook refer to the page under Inserting Functions
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext
