View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
Pete_UK Pete_UK is offline
external usenet poster
 
Posts: 8,856
Default Count Number or words in Cell

Thanks for pointing that out, Ron. I see that Dave has come up with a
way of coping with an empty cell.

Pete

On Aug 15, 3:06 pm, Ron Rosenfeld wrote:
On Wed, 15 Aug 2007 06:45:33 -0700, Pete_UK wrote:
If the words are separated by a single space then you can compare the
length of the cell with the length of the cell after spaces have been
removed and add one. Like this:


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


If you had "Mary had a lamb" in A1, then this formula will return 4.


Hope this helps.


Pete


And your formula would also return 1 with a blank cell. You need to test for
it.
--ron