Extracting name from string - training comma

Nyanko

Active Member
Joined
Sep 1, 2005
Messages
437
Hi,

This seemed like a fairly simple task and I have gotten 99% of it apart from a small issue.

My original data is stored

Surname, Firstname
Smith, John

and I'm looking to change (via formulas only) to

Initial Surname
J Smith

I'm using the following formula
Code:
=LEFT(TRIM(IF(ISERROR(FIND(" ",G4,1)),G4,MID(G4,FIND(" ",G4,1)+1,IF(ISERROR(FIND(" ",G4,FIND(",",G4,1)+2)),LEN(G4),FIND(" ",G4,FIND(",",G4,1)+2))-FIND(" ",G4,1)))))&" "&LEFT(G4,FIND(", ",G4&" "))

But I end up with
J Smith,

and it's that **** comma at the end I can't figure out how to get rid of :) Any help ?




edit - Dammit I meant to call the thread TRAILING comma not TRAINING. I can't figure out how to change
 
Last edited:

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Here's one way:
<b>Excel 2002</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style=";">Surname, Firstname</td><td style=";">F Surname</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style=";">Smith, John</td><td style=";">J Smith</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B1</th><td style="text-align:left">=LEFT(<font color="Blue">TRIM(<font color="Red">MID(<font color="Green">SUBSTITUTE(<font color="Purple">A1,",",REPT(<font color="Teal">" ",50</font>)</font>),50,50</font>)</font>)</font>)&" "&LEFT(<font color="Blue">A1,FIND(<font color="Red">",",A1</font>)-1</font>)</td></tr></tbody></table></td></tr></table><br />
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,753
Members
452,940
Latest member
rootytrip

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