So, for example, with the text string "one two three" the result is going to look like this:
With hyphens representing spaces for readability. Keep in mind that there will be 100 spaces between each word.
Next, the RIGHT function extracts 100 characters, starting from the right. The result will look like this:
Finally, the TRIM function removes all leading spaces, and returns the last word.
Note: We are using 100 arbitrarily because that should be a big enough number to handle very long words. If you have some odd situation with super long words, bump this number up as needed.
Handling inconsistent spacing
If the text you are working with has inconsistent spacing (i.e. extra spaces between words, extra leading or trailing spaces, etc.) This formula won't work correctly. To handle this situation, add an extra TRIM function inside the substitute function like so:
In this example, the goal is to extract the nth word from the text string given in column B. Excel does not currently have a function dedicated to this task, so this formula is a workaround. At the core, this formula takes a text string with spaces...
FIND returns the position (as a number) of the first occurrence of a space character in the text. This position, minus one, is fed into the LEFT function as num_chars. The LEFT function then extracts characters starting at the the left side of the...
Excel doesn't have a dedicated function for counting words in a cell. However, with a little ingenuity, you can create such a formula using the SUBSTITUTE and LEN functions, with help from TRIM, as shown in the example. At a high level, this formula...
The formula shown in this example uses a series of nested SUBSTITUTE functions to strip out parentheses, hyphens, colons, semi-colons, exclamation marks, commas, and periods. The process runs from the inside out, with each SUBSTITUTE replacing one...
The Excel SUBSTITUTE function replaces text in a given string by matching. For example =SUBSTITUTE("952-455-7865","-","") returns "9524557865"; the dash is stripped. SUBSTITUTE is case-sensitive and does not support wildcards.
Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.