Explanation

LAMBDA functioncan be used to create custom, reusable functions in Excel.

This example illustrates a feature called recursion, in which a function calls itself.

Recursion can be used to create elegant, compact, non-redundant code.

Excel formula: LAMBDA count words

This example is primarily proof of concept, to show a very simple recursive LAMBDA function.

MID strips one character at a time, which is why this formula is recursive.

The result is given to the StripTrailingChars function, along with the original value forchar.

Excel formula: Strip non-numeric characters

When all the target trailing characters have been removed, the function returns the current value forstr.

you’re able to find more general information about the LAMBDA functionhere.

For example, =MID(“apple”,2,3) returns “ppl”.

Excel formula: LAMBDA replace characters recursive

LEN will also count characters in numbers, but number formatting is not included.

Excel LAMBDA function

Excel MID function

Excel LEN function