Formula
=LEFT(Text,SEARCH("^^",SUBSTITUTE(Text," ","^^",LEN(Text)-LEN(SUBSTITUTE(Text," ","")))))
Four math functions used in the combination to extract the desired text from the given text. The functions used in the formula was
LEFT - used to extract the number of text from the left of the sentence
SEARCH - Used to search the particular text / word from the sentence and locate the text in the sentence
SUBSTITUTE - used to replace the particular text / word in the sentence
LEN - used to count the number of string in the sentence
Explanation
Simple idea to extract the text before the final space in the sentence is to use the LEFT function and locate the position of the last space or any specific character need to be located.
=LEFT(Text, Location of the last space)
Locating of last space is the difficult task. To locate the last space, we need to use combination of formula.
First we need to find out number of space in the sentence using the formula
LEN(Text)-LEN(SUBSTITUTE(Text," ",""))
The formula returns the number of space in the sentence.
SUBSTITUTE(Text," ","^^",No of space)
The formula substitute the special character ^^ in the last place of the space.
SEARCH("^^",Text)
The formula return the location of the special character ^^ which is nothing but location of the last space in the sentence.
Combining all the above functions we get the consolidate the formula as
No comments:
Post a Comment