Learn how to abbreviate names or words using regular Excel functions or the ABBREVIATE user-defined function.
First, we will introduce the ABBREVIATE function, using a UDF to simplify and speed up the task. Then, in the second part of the article, we’ll apply a custom formula to abbreviate names containing capital letters.
Today’s tutorial is a part of our definitive guide on Excel Formulas.
How to abbreviate names in Excel?
Here are the steps to abbreviate names or words in Excel:
- Open Excel
- Type =ABBREVIATE(B1)
- Press Enter.
- The formula returns the abbreviated name from the specified cell.
ABBREVIATE function
The ABBREVIATE function returns the abbreviation for the supplied string. User-defined functions provide huge advantages when you are working with string manipulation formulas.
Syntax:
=ABBREVIATE(cell_reference)
Arguments:
The function uses one required argument: the cell reference.
In the example shown, the formula in D3 is:
=ABBREVIATE(B3)
To implement this user-defined function into your spreadsheet, do the following:
- Use the Alt + F11 keyboard shortcut to open the VBA Editor
- Right-click on the ThisWorkbook
- Add a new module
- Copy and insert the snippet
- Save your workbook as a .xlsm file.
Here is the code:
Function Abbreviate(strC As String) As String
Dim Company() As String
Dim i As Byte, j As Byte
Dim strAbbr As String
Company() = Split(strC, " ")
i = UBound(Company())
If i > 0 Then
For j = 0 To i
strAbbr = strAbbr & UCase(Left(Company(j), 1))
Next j
Else
strAbbr = strC
End If
Abbreviate = strAbbr
End Function
The next example below uses an advanced formula to extract the initials from names or create acronyms. To speed up your work, download our DataFX add-in, which expands Excel’s built-in library with user-defined functions.
Using regular functions
Let’s see how to check when a cell contains specific text using a simple combination of regular Excel functions. It looks complex, but try to use it if you are a function geek.
=TEXTJOIN(“”,1,IF(ISNUMBER(MATCH(CODE(MID(A1,ROW(INDIRECT(“1:”&LEN(A1))),1)),
ROW(INDIRECT(“65:90”)),0)),MID(A1,ROW(INDIRECT(“1:”&LEN(A1))),1),””))
Okay, please take a closer look at the formula and evaluate it from the inside out.
- The INDIRECT function has a parameter: numbers between 65 and 90. This range corresponds to the ASCII codes for all capital letters between A and Z.
- We use MID, ROW, INDIRECT, and LEN functions to convert a string to letters.
- TEXTJOIN will concatenate the extracted letters into one word.
Note: A special requirement before applying the formula is that the source text must include capitalized words.
Related Formulas and Examples
- Get the first name from a full name
- Remove the first character
- Trim text to n words
- Split text with delimiter