Hi - Dave here.

Happy Friday, and Happy New Year!

I'm still working on a project to update many of my older formulas to use new functions in Excel.

Below is another interesting example of an older more complicated formula being replaced by a simple formula that works just like you'd expect it to.

The old version of the formula looks like this:

=LEN(TRIM(B5))-LEN(SUBSTITUTE(B5," ",""))+1

The new version of the formula (below) looks like this:

=COUNTA(TEXTSPLIT(TRIM(B5)," "))

Counting words with the TEXTSPLIT function

[Download the workbook and read the full explanation]

The old formula is an indirect approach that involves counting words by counting spaces:
 
  1. Clean up the text with TRIM
  2. Count characters in the result with LEN
  3. Remove all space characters with SUBSTITUTE
  4. Count characters in the result with LEN
  5. Subtract the second count from the first count
  6. Add 1 to get a final word count

Ugh. This works because the word count is equal to the number of spaces + 1, but it's a messy and non-intuitive process.

The new formula contains 3 simple and logical steps:
 
  1. Clean up the text with TRIM
  2. Create a list of words with TEXTSPLIT
  3. Count the words in the list with COUNTA

This is so much better! Not only is the formula shorter, but the steps just make sense. Bravo to the Excel team for getting new functions like TEXTSPLIT into Excel. They are game changers. The article above contains both formulas and a full explanation. Download the workbook and try it out for yourself.

Excel formulas

We maintain a list of over 500 working formulas here.

If you need more structure, we also offer video training.

Have a great weekend!

Dave

 

Exceljet Logo
Exceljet
P.O. Box 4804
Salt Lake City, UT 84110

Copyright © 2023 Exceljet, All rights reserved.
You received this email because you are subscribed to our newsletter.
To unsubscribe, click the link below.