In the example, the active cell contains this formula: At a high level, the formula replaces the last space in the name with an asterisk “” and then uses FIND to determine the position of the asterisk in the name. The position is used to work out how many characters to extract with RIGHT. How does the function replace only the last space? This is the clever part. Buckle up, the explanation gets a bit technical. They key to this formula is this bit: Which does the actual replacement of the last space with “”. SUBSTITUTE has a fourth (optional) argument that specifies which “instance” of the find text should be replaced. If nothing is supplied for this argument, all instances are replaced. However, if, say the number 2 is supplied, only the second instance is replaced. In the snippet above, instance is calculated using the second SUBSTITUTE: Here, the length of the name without any spaces is subtracted from the actual length of the name. If there’s only one space in the name, it produces 1. If there are two spaces, it the result is 2, and so on. In the example name in B4, there are two spaces in the name, so we get: 15 - 13 = 2 And two is used as in the instance number: which replaces the second space with “”. The name then looks like this: “Susan AnnChang” The FIND function then takes over to figure out where the “*” is in the name: The result is 10 (the * is in the 10th position) which is subtracted from the total length of the name: Since the name is 15 characters, we have: 15-10 = 5 The number 5 is used by RIGHT like so: Which results in “Chang” As, you can see, it’s a lot of work above to calculate that simple 5!

Handling inconsistent spaces

Extra spaces will cause problems with this formula. One solution is to use the TRIM function first to clean things up, then use the parsing formula.

Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.