Extract First Letter of Each Word in Google Sheets: Array Formula

Published on

Extracting the first letter of each word in a string is easy in Google Sheets. The real challenge is transforming it into an array formula.

To extract the first letter of each word, we will first split the string and then use the REGEXEXTRACT or LEFT function to extract the first character.

Let’s assume cell A3 contains the string “North Atlantic Treaty Organization”.

I want to extract the letters “N”, “A”, “T”, and “O”, and later join them as an abbreviation like “NATO”. Here is how we do that in Google Sheets.

Formulas to Extract First Letters from Each Word in Google Sheets

Using SPLIT and LEFT Combo:

=ArrayFormula(LEFT(SPLIT(A3, " "), 1))
SPLIT and LEFT combo for letter extraction in Google Sheets

Here, the SPLIT function splits the string at each space character, and the LEFT function extracts 1 character from the left of each split word.

Using SPLIT and REGEXEXTRACT Combo:

=ArrayFormula(REGEXEXTRACT(SPLIT(A3, " ")&"", "."))

In this case, the SPLIT function splits the string. We added "" to the split words to ensure they are treated as text, a precaution to avoid errors in case any split part is numeric. Then the REGEXEXTRACT function extracts one character from each word.

Both of these formulas use the ARRAYFORMULA function since they return array results.

Can These Formulas Be Used in a Range?

You can use both formulas in a range like A3:A. However, remember to include the IFERROR wrapper; otherwise, you will see error values in rows where A3:A is blank.

Here are the array formulas to extract the first letter of each word in a string in Google Sheets:

=ArrayFormula(IFERROR(LEFT(SPLIT(A3:A, " "), 1)))
=ArrayFormula(IFERROR(REGEXEXTRACT(SPLIT(A3:A, " ")&"", ".")))
Extracting the first letter of each word in a string in Google Sheets

If you don’t use the IFERROR wrapper, the first formula will return #VALUE! errors in blank rows. The second formula will return #VALUE! errors in blank rows and #N/A errors in empty columns as well.

Extracting and Joining the First Letter of Each Word to Form an Abbreviation

When you extract the first characters from a cell, not a range, you can combine the characters extracted to form an abbreviation using the JOIN function as follows:

=JOIN("", ArrayFormula(LEFT(SPLIT(A3, " "), 1)))
=JOIN("", ArrayFormula(REGEXEXTRACT(SPLIT(A3, " ")&"", ".")))

This will return ‘NATO’ instead of ‘N’, ‘A’, ‘T’, and ‘O’ individually.

If you want to auto-extend the formula down the column, you can use the BYROW function as follows:

=BYROW(
   ArrayFormula(IFERROR(LEFT(SPLIT(A3:A, " "), 1))), 
   LAMBDA(val, JOIN("", val))
)
Extracting the first letter of each word to form abbreviations in Google Sheets

You can replace ArrayFormula(IFERROR(LEFT(SPLIT(A3:A, " "), 1))) with ArrayFormula(IFERROR(REGEXEXTRACT(SPLIT(A3:A, " ")&"", "."))) as well.

If you want the joined text separated by a space, replace the delimiter in the JOIN function, i.e., "" with " ". So the formula will be:

=BYROW(ArrayFormula(IFERROR(LEFT(SPLIT(A3:A, " "), 1))), LAMBDA(val, JOIN(" ", val)))

Note: The BYROW function is resource-intensive, and you may encounter performance issues when applying it to a very large dataset.

You can skip the following section as it just details the functionality of the above formula.

Formula Explanation

The BYROW function applies a lambda function to each row in an array and groups each row into a single value. The result will be a new column.

Syntax:

BYROW(array_or_range, lambda)
  • array_or_range: ArrayFormula(IFERROR(LEFT(SPLIT(A3:A, " "), 1))) (one of the formulas that splits strings and extracts the first letter of each word).
  • lambda: LAMBDA(val, JOIN("", val)) (The JOIN function that concatenates each element in the array, defined as ‘val’, using the "" delimiter).

This returns a new column array formed by grouping each row in array_or_range into a single concatenated value. The grouped value for a row is obtained by applying a lambda on that row.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

More like this

Highlight Upcoming Birthdays in Google Sheets

When highlighting upcoming birthdays in Google Sheets, one important aspect is ignoring the year...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.