Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Words in String 3

Status
Not open for further replies.

dunkyn

Technical User
Apr 30, 2001
194
US
What function may I use to count the number of words in a string?
 
This should do the trick:
---------------------------------
UBOUND(Split({Your_String}, " "))
---------------------------------

Cheers,
- Ido

CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
I tried this, and it did work neatly on well-edited text. But for more messy input, it counted excess embedded spaces as 'words' - separate items, presumably. Madawc Williams
East Anglia
Great Britain
 
Madawc

Solution -

I had the same problem, but solved it with enclosing the formula with Trim(). Works wonderfully!
 
TRIM() may solve leading or trailing spaces, but would not solve cases where there is more than one space between the words.

To solve cases where there are double spaces within the string, use:
------------------------------------------------
UBOUND(Split(REPLACE({Your_String}," "," "), " "))
------------------------------------------------
This starts by replacing any double space within the string by a single space.

Cheers,
- Ido


CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Great idea. You must have encountered this once upon a time.

Thanks for the input!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top