简体   繁体   中英

Create separate column based on email address, using Excel or SQL

I have a column in Excel with the following

Employee
Mickey D. Mouse mickey@disney.com

I want it to look like

Employee || Email
Mickey D. Mouse || mickey@disney.com

In Excel, if I use Text to Column it looks like this

Mickey || D. || Mouse || mickey@disney.com

So how can I separate on JUST the email, and leave the name in ONE column?

Please provide help in either Excel or SQL.

In Excel, assuming that your complete data is consistent as depicted in your question, you can use below approach.

Assuming that source data is in cell A1 then formula in cell C1 would be

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99))

And then to get the rest in B1 following can be implemented

=TRIM(SUBSTITUTE(A1,C1,""))

OK I just got the email out with this from https://www.extendoffice.com/documents/excel/1272-excel-extract-email-address.html

=IFERROR(TRIM(RIGHT(SUBSTITUTE(LEFT(AL2,FIND(" ",AL2&" ",FIND("@",AL2))-1)," ",REPT(" ",LEN(AL2))),LEN(AL2))),0)

And extracted the name with

=IF(J2=0, (LEFT(H2, SUM(LEN(H2)-LEN(J2)))), (LEFT(H2, SUM(LEN(H2)-LEN(J2)-1))))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM