Swaping order of names in Cell , creates a leading space

Godders199

Active Member
Joined
Mar 2, 2017
Messages
313
Office Version
  1. 2013
Hello, i want to use the following formula to swap the order of names within a cell, however it is creating a leading space, before the first name.

=MID(A2&" "&A2,FIND(",",A2)+1,LEN(A2))

I know the Trim function can remove this, but not sure how to combine into this formula.

So my question is firstly, is there a reason my current formula creates the leading space?, secondly if my formula is correct how do i combine the Trim function ?

Thanks for your help.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
just wrap the whole thing in Trim

As to why, I could only guess as I don't have the live data.

=TRIM(MID(A2&" "&A2,FIND(",",A2)+1,LEN(A2)))
 
Upvote 0
Again, without any sample data it's a guess, but maybe an alternative.

=MID(A2&" "&A2,FIND(",",A2)+2,LEN(A2)-1)
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,635
Members
452,661
Latest member
Nonhle

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