Extracting Name from Cell with Date and Name Data

Jessrozy11

New Member
Joined
Mar 1, 2019
Messages
6
Hi,

I have a cell that has date and name (last name, first name):
01/27/2019-Gxxxxxxx, Txxxxx
01/26/2019-Kxxxxxxx, Exxx
01/02/2019-Mxxxx, Axxxxxxx
01/27/2019-Gxxxxxxx, Txxxxx

<tbody>
</tbody>

I need to remove the date and only see the name and preferably in the opposite order. Right now it is showing last name, first name. Prefer first name last name.

I'd like to see data as:
Txxxxx Gxxxxxxx
Exxx Kxxxxxxx
Axxxxxxx Mxxxx
Txxxxx Gxxxxxxx

I tried =MID($A2, 12, 30) but I’m worried the date format may come through as 01/2/2019 for the single digit days. I also wasn’t able to figure out how to switch the name order either. Is there an easier way or different formula I can use?

Greatly appreciated!
Jessica
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
=RIGHT(A1,LEN(A1)-FIND("-",A1,1)) will give you the same results that you received with your formula without having to worry about the date.
 
Upvote 0
Done with PowerQuery aka Get&Transform

rawraw.2raw.1
01/27/2019-Gxxxxxxx, TxxxxxTxxxxxGxxxxxxx
01/26/2019-Kxxxxxxx, ExxxExxxKxxxxxxx
01/02/2019-Mxxxx, AxxxxxxxAxxxxxxxMxxxx
01/27/2019-Gxxxxxxx, TxxxxxTxxxxxGxxxxxxx

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Extracted Text After Delimiter" = Table.TransformColumns(Source, {{"raw", each Text.AfterDelimiter(_, "-"), type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Text After Delimiter", "raw", Splitter.SplitTextByDelimiter(", ", QuoteStyle.Csv), {"raw.1", "raw.2"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Split Column by Delimiter",{"raw.2", "raw.1"})
in
    #"Reordered Columns"[/SIZE]
 
Upvote 0
Welcome to the Board!

To reverse the first/last name at the same time, try this:
Code:
=MID(A1,FIND(", ",A1)+2,LEN(A1))&" "&MID(A1,FIND("-",A1)+1,FIND(",",A1)-FIND("-",A1)-1)
 
Upvote 0
After using this code, I realized there are additional / unnecessary spaces after the first name in the original cell. Any recommendation on how to eliminate that space?

Before code: 01/27/2019-Gxxxxxxx, Txxxxx
After code: Txxxxx Gxxxxxxx

Thank you!
 
Upvote 0
Sorry! I'm new to this. I used code:
=MID(A1,FIND(", ",A1)+2,LEN(A1))&" "&MID(A1,FIND("-",A1)+1,FIND(",",A1)-FIND("-",A1)-1)
 
Upvote 0
You can apply the TRIM function to my code to get rid of any extra spaces, i.e.
Code:
=[COLOR=#ff0000]TRIM[/COLOR](MID(A1,FIND(", ",A1)+2,LEN(A1))) & " " & [COLOR=#ff0000]TRIM[/COLOR](MID(A1,FIND("-",A1)+1,FIND(",",A1)-FIND("-",A1)-1))
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top