Posts Tagged text formula
Text Split with Excel Formula – Part II
Hi friends,
Here goes the Text Split formula Part II, which will explain how to split First Name, Middle Name and Last Name.
Of course, you can use this many other ways too, so try to understand the logic behind this.
Formulas Used:
Just like previous part, we are also going to use Left, Right & find formulas.
All the three formulas are much simple to use and the real magic is binding them together to get desired results.
LOGIC:
In the first part, we had used find to determine the location of space between two words and then we split it with left & right.
Now in this part we are going to find out further how to find out second space in the given string.
Situation:
If you have a string ‘Firstname Middlename Lastname’, in A3 how you will separate this text with formulas so that you will have firstname, middlename and lastname in separate columns.
Firstname:
Very easy just like what we did in the last part find out the place of separator and use left function.
The formula for the given example is…=LEFT(A3,FIND(” “,A3,1))
Middlename:
This is most interesting part that everybody wants. Here you need to use all the three functions together. First you find out 2nd location of separator and using left formula you will get string ‘firstname middlename’. Then using right formula as in part one you can separate middlename. As this is quiet complicated I will explain this step by step and then together.
Step 1: Find 2nd location of separator formula is … =FIND(” “,A3,FIND(” “,A3,1)+1)
Note: remember to add ‘1′ to last separator location to find out next, otherwise it will keep giving you same results.
Step 2: Find string ‘firstname middlename’ formula is … =LEFT(A3,FIND(” “,A3,FIND(” “,A3,1)+1))
Step 3: Use ‘Right’ function to separate middlename from string in step 2, formula is…=RIGHT(LEFT(A3,FIND(” “,A3,FIND(” “,A3,1)+1)),FIND(” “,A3,1))
Lastname:
Comparatively this is easy, and similar to what we did in last part the only difference is instead of 1st location of separator we are going to use last location of separator.
The formula for the given example is… =RIGHT(A3,LEN(A3)-FIND(” “,A3,FIND(” “,A3,1)+1))
Conclusion:
This way you can split ‘n’ number words with any given separator. Try to find out way to use string functions differently it has enormous power.
Please add your feedback and comments below.
4 comments December 22, 2008
Text Split with Excel Formula – Part I
It always happens that you need to use text to column feature in excel. for some it’s rare but from some it’s everyday exercise. Think about the advantages that you will get if you can split text with formulas.
Let’s see how you can do that with example:
If you have a string ‘Firstname Lastname’, in A3 how you will separate this text with formulas so that you will have firstname and lastname in separate columns.
There are two formulas involved.
Left and right
How to Use left formula for fisrtname:
the main factor in this formula is finding out the string length of the firstname as it will vary. The solution is find out the place of separator (space in given example)
The formula for given example will be… =left(A3,find(” “,A3,1))
Now the difficult part of it that is the right formula use for lastname:
here as well the main factor is finding out the length of the string lastname as it will also vary everytime. so to find out the length we will first find out the place of separator (space in given example) and reduce it from the total length.
The formula for given example will be… =right(A3,len(A3)-find(” “,A3,1))
In next part we will see how can we use the formulas to split text “Firstname Middlename Lastname”.
4 comments July 13, 2008