Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-05-2016, 06:41 PM
dpic44's Avatar
dpic44 dpic44 is offline Split data from name field Mac OS X Split data from name field Office for Mac 2011
Novice
Split data from name field
 
Join Date: Feb 2016
Posts: 8
dpic44 is on a distinguished road
Default Split data from name field

I need to extract the first name, middle initial and last name from a cell. I am able to extract all of them when there is a middle initial, however I get an error if the name has no middle initial. Attached is a spreadsheet with my formulas.



Thank you for any help you can give me.

FORMULAS
First Name Formula =LEFT(A7,FIND(" ",A7))
Middle Initial =IFERROR(MID(A9,FIND(".",A9)-1,2),MID(A9,FIND(" ",A9)+1,2))
Last Name Formula =IFERROR(RIGHT(A7,LEN(A7)-FIND(".",A7)-1),RIGHT(A7,LEN(A7)-FIND(" ",A7)-2))

RESULTS
Full Name First Name Middle Initial Last Name
Jeffrey R. Evers Jeffrey R. Evers
Robert R Gains Robert R Gains
Deborah Harris Deborah Ha rris

* Error - Works if middle initial has a period or if middle initial has no period, doesn't work if there is no middle initial
Attached Files
File Type: xlsx Left,Mid,Right Formulas.xlsx (47.5 KB, 11 views)

Last edited by dpic44; 02-05-2016 at 07:59 PM. Reason: Added formulas
Reply With Quote
  #2  
Old 02-05-2016, 09:06 PM
BudVitoff BudVitoff is offline Split data from name field Windows 7 64bit Split data from name field Office 2007
Advanced Beginner
 
Join Date: Sep 2011
Posts: 52
BudVitoff is on a distinguished road
Default

You say it works if middle initial has no period, but for line 9 it did not find a period, so the error return was a null, not the "R". The non-error return was the result of the formula, whose MID value suffered from the failed FIND getting a #VALUE! error -- at which point the -1,2 part is meaningless.

If I'm right so far, then line 10 also suffers because it depends on finding a period.
Reply With Quote
  #3  
Old 02-05-2016, 09:14 PM
BudVitoff BudVitoff is offline Split data from name field Windows 7 64bit Split data from name field Office 2007
Advanced Beginner
 
Join Date: Sep 2011
Posts: 52
BudVitoff is on a distinguished road
Default

Oops! I was depending on the results shown on the spreadsheet, not the ones in your post.

Now I see that the formulas you show in your spreadsheet are different from the ones in your post. Personally, I'd appreciate it if you took another look at what you've given us and make it consistent so that we can play nice.

Now regarding Deborah Harris, my guess is that there are two trailing spaces following her last name in the live data that are invisible, as spaces tend to be. Applying your code to this data would result in extracting a last name that looks like rris^^ (where ^ represents a space). This is why in all cases where leading or trailing spaces could present a problem, the data should be "trimmed"; i.e., those spaces should be removed from the data before applying any logic.
Reply With Quote
  #4  
Old 02-06-2016, 01:05 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Split data from name field Windows 7 64bit Split data from name field Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,943
Pecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond repute
Default

Quote:
Originally Posted by BudVitoff View Post
. This is why in all cases where leading or trailing spaces could present a problem, the data should be "trimmed"; i.e., those spaces should be removed from the data before applying any logic.
Which can be done using the TRIM function ( whether or not spaces need to be removed)
__________________
Using O365 v2503 - Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #5  
Old 02-06-2016, 01:38 AM
xor xor is offline Split data from name field Windows 10 Split data from name field Office 2016
Expert
 
Join Date: Oct 2015
Posts: 1,101
xor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to all
Default Split data from name field

Maybe like the attached.
Attached Files
File Type: xlsx Left-Mid-Right.xlsx (10.7 KB, 11 views)
Reply With Quote
  #6  
Old 02-06-2016, 03:59 AM
BudVitoff BudVitoff is offline Split data from name field Windows 7 64bit Split data from name field Office 2007
Advanced Beginner
 
Join Date: Sep 2011
Posts: 52
BudVitoff is on a distinguished road
Default

XOR: Yeah, that would be much better. There's only one anomaly left: What's the significance of lines 18-20? One can't infer that they are the result of executing the formulas shown, because the result in line 10 shows the error.

PECOFLYER: I used the word "trimmed" intentionally, because I was aware of the TRIM function; however, when Excel Help appeared to discuss TRIM only in terms of editing movies, I decided against mentioning the function. Oddly enough, I did learn something new though. TRIM not only removes leading and trailing spaces, but it also compresses spaces between words; i.e., it removes redundant spaces.

You're never too old to learn something new.
Reply With Quote
  #7  
Old 02-06-2016, 10:50 AM
dpic44's Avatar
dpic44 dpic44 is offline Split data from name field Mac OS X Split data from name field Office for Mac 2011
Novice
Split data from name field
 
Join Date: Feb 2016
Posts: 8
dpic44 is on a distinguished road
Default

Quote:
Originally Posted by xor View Post
Maybe like the attached.
Thank you! I'm going over the formulas now. Definitely advanced for my level.
Reply With Quote
  #8  
Old 02-06-2016, 10:44 AM
dpic44's Avatar
dpic44 dpic44 is offline Split data from name field Mac OS X Split data from name field Office for Mac 2011
Novice
Split data from name field
 
Join Date: Feb 2016
Posts: 8
dpic44 is on a distinguished road
Default

Quote:
Originally Posted by BudVitoff View Post
Oops! I was depending on the results shown on the spreadsheet, not the ones in your post.

Now I see that the formulas you show in your spreadsheet are different from the ones in your post. Personally, I'd appreciate it if you took another look at what you've given us and make it consistent so that we can play nice.

Now regarding Deborah Harris, my guess is that there are two trailing spaces following her last name in the live data that are invisible, as spaces tend to be. Applying your code to this data would result in extracting a last name that looks like rris^^ (where ^ represents a space). This is why in all cases where leading or trailing spaces could present a problem, the data should be "trimmed"; i.e., those spaces should be removed from the data before applying any logic.
Yes, I apologize for that. I realized I had a mistake in the original file and resubmitted with the formulas in the post.

Thank you for your help! I'm looking at the following posts now and will try to digest it. It's a little advanced for me
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to split merged data into vertical saperate cells cheekugreat Excel 5 10-11-2014 05:53 AM
Split data from name field How to format WORD data using edit field? Azuki Mail Merge 2 04-01-2013 06:08 PM
Merge field source data field kckay Mail Merge 4 03-25-2013 11:06 AM
Split data from name field Mail Merge - If a field is black, take the data from the row below? mikeprent Mail Merge 5 01-05-2012 04:52 AM
Split data from name field Split Data from One Cell Into Two Karen615 Excel 3 09-20-2011 06:36 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:51 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft