LAMBDA · Text
Proper name LAMBDA
xl.proper.name applies title case and capitalizes the letter after Mc. mcdonald becomes McDonald. PROPER alone returns Mcdonald.
Syntax =xl.proper.name(name)
=LAMBDA(name,
LET(
cleaned, PROPER(TRIM(name)),
IF(LEFT(cleaned, 2)="Mc",
"Mc" & UPPER(MID(cleaned, 3, 1)) & MID(cleaned, 4, 999),
cleaned)
)
)Arguments
| Name | Required | What to pass |
|---|---|---|
| name | Required | A personal name. Extra spaces are trimmed. A leading Mc is recapitalized. |
Examples
A surname PROPER gets wrong
=xl.proper.name("mcdonald")Result McDonald
| A | B | |
|---|---|---|
| 1 | Raw | mcdonald |
| 2 | Proper | McDonald |
xl.proper.name is PROPER plus the Mc fix people notice on a mailing list. mcdonald becomes McDonald. maria lopez becomes Maria Lopez, because that name does not start with Mc and PROPER is enough.
o'brien becomes O'Brien from PROPER alone. The apostrophe already starts a new word.
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.proper.name, 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.proper.name(...).
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 and PROPER run first. If the first two letters are Mc, the third letter is forced to uppercase and the rest of PROPER’s result is kept. Mcdonald therefore becomes Mc + D + onald.
Limits
Mac, Van, and de are not special. A name that merely starts with the letters Mc, such as a given name, gets the same treatment. The function does not lowercase a shouty particle in the middle of a string beyond what PROPER already does.