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
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
It can be text to columns but with Fixed Width / Next / Create a break line after character 5.
 
Upvote 0
Or try this


<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:115.01px;" /><col style="width:76.04px;" /><col style="width:170.14px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td >Original Code</td><td >First 5</td><td >Trailing Character</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="text-align:right; ">99999</td><td style="text-align:right; ">99999</td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td >99999-25</td><td style="text-align:right; ">99999</td><td style="text-align:right; ">-25</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td >99999R</td><td style="text-align:right; ">99999</td><td >R</td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b></b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >B2</td><td >=LEFT(A2,5)</td></tr><tr><td >C2</td><td >=MID(A2,6,LEN(A2)-5)</td></tr></table></td></tr></table>
 
Upvote 0
It can be text to columns but with Fixed Width / Next / Create a break line after character 5.


That wouldn't strip out the - and it doesn't exist in all of them.

Perhaps:


Excel 2010
ABC
1Original CodeFirst 5Trailing Character
29999999999 
399999-259999925
499999R99999R
Sheet1
Cell Formulas
RangeFormula
B2=LEFT(A2,5)
B3=LEFT(A3,5)
B4=LEFT(A4,5)
C2=MID(SUBSTITUTE(A2,"-",""),6,255)
C3=MID(SUBSTITUTE(A3,"-",""),6,255)
C4=MID(SUBSTITUTE(A4,"-",""),6,255)
 
Upvote 0
Hi @Excel1991, In your example you deleted the "-". Do you need to remove the "-"? Besides the "-" is there any other character you want to remove?
 
Upvote 0
That wouldn't strip out the - and it doesn't exist in all of them.

Perhaps:

Excel 2010
ABC
Original CodeFirst 5Trailing Character
99999-25
99999RR

<tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]99999[/TD]
[TD="align: right"]99999[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]99999[/TD]
[TD="align: right"]25[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]99999[/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH]B2[/TH]
[TD="align: left"]=LEFT(A2,5)[/TD]
[/TR]
[TR]
[TH]C2[/TH]
[TD="align: left"]=MID(SUBSTITUTE(A2,"-",""),6,255)[/TD]
[/TR]
[TR]
[TH]B3[/TH]
[TD="align: left"]=LEFT(A3,5)[/TD]
[/TR]
[TR]
[TH]C3[/TH]
[TD="align: left"]=MID(SUBSTITUTE(A3,"-",""),6,255)[/TD]
[/TR]
[TR]
[TH]B4[/TH]
[TD="align: left"]=LEFT(A4,5)[/TD]
[/TR]
[TR]
[TH]C4[/TH]
[TD="align: left"]=MID(SUBSTITUTE(A4,"-",""),6,255)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]


Could you explain how the "255" portion of the formula works?
 
Last edited:
Upvote 0
It just means 255 characters. It ensures that you get, in all likelihood, however many characters you have in your string.
 
Upvote 0

Forum statistics

Threads
1,223,702
Messages
6,173,967
Members
452,539
Latest member
delvey

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