LAMBDA · Text
First word LAMBDA
xl.first.word returns the text before the first space. Maria Elena Lopez returns Maria. A single word is returned unchanged.
Syntax =xl.first.word(text)
=LAMBDA(text,
LET(
cleaned, TRIM(text),
IFERROR(TEXTBEFORE(cleaned, " "), cleaned)
)
)Arguments
| Name | Required | What to pass |
|---|---|---|
| text | Required | A phrase. The first space is the cut. |
Examples
The given name
=xl.first.word("Maria Elena Lopez")Result Maria
| A | B | |
|---|---|---|
| 1 | Name | Maria Elena Lopez |
| 2 | First word | Maria |
xl.first.word returns Maria from Maria Elena Lopez. The cut is the first space. A one-word cell comes back unchanged, because TEXTBEFORE’s #N/A is replaced with the trimmed text.
Pair it with xl.last.word when you want both ends and do not need the middle. xl.split.name keeps the middle attached to the remainder.
Add it to the workbook
Copy the formula in the block above, including the line breaks. Choose Formulas, Name Manager, New. Set the name to xl.first.word, the scope to Workbook, and paste into Refers to. Excel Labs can do the same step: open the Advanced Formula Environment, add that name, and save it back to the workbook. A cell then calls =xl.first.word(...).
The name needs Microsoft 365, Excel 2024, or Excel for the web. Excel 2021 returns #NAME? for LAMBDA even when it already has XLOOKUP, FILTER, or LET.
How it works
TRIM removes extra spaces so the first character is not a space. TEXTBEFORE takes everything before the first space. IFERROR returns the whole string when there is no space.
Limits
Hyphens are not spaces. Mary-Jane stays Mary-Jane. A nonbreaking space is not a normal space unless you run xl.collapse.space first.