Formula for Separating Digits after nth Digit

Excel1991

Board Regular
Joined
Aug 1, 2018
Messages
58
Hi all,

I have a list of codes which can be of varying lengths ("99999" or "99999-25" or "99999R") and I would like to take the put the first 5 digits in one column and whatever comes after the first 5 digits in the net column?

[TABLE="width: 500"]
<tbody>[TR]
[TD]Original Code[/TD]
[TD]First 5[/TD]
[TD]Trailing Character[/TD]
[/TR]
[TR]
[TD]99999[/TD]
[TD]99999[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]99999-25[/TD]
[TD]99999[/TD]
[TD]25[/TD]
[/TR]
[TR]
[TD]99999R[/TD]
[TD]99999[/TD]
[TD]R[/TD]
[/TR]
</tbody>[/TABLE]

I dont think text to columns would work because i do not have a common deliminator. Does anyone know of a formula that can be used in this instance? Thank you
 
And just to prove there is almost always more than one way to do things in Excel, here are three more formula that will return those trailing characters (if any)...

=MID(A2,6+(MID(A2,6,1)="-"),99)

=MID(A2,6+COUNTIF(A2,"*-*"),99)

=REPLACE(A2,1,5+(MID(A2,6,1)="-"),"")
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,223,703
Messages
6,173,977
Members
452,540
Latest member
haasro02

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