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?

Original CodeFirst 5Trailing Character
9999999999
99999-259999925
99999R99999R

<tbody>
</tbody>

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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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
1Original CodeFirst 5Trailing Character
29999999999
399999-259999925
499999R99999R

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B2=LEFT(A2,5)
C2=MID(SUBSTITUTE(A2,"-",""),6,255)
B3=LEFT(A3,5)
C3=MID(SUBSTITUTE(A3,"-",""),6,255)
B4=LEFT(A4,5)
C4=MID(SUBSTITUTE(A4,"-",""),6,255)

<tbody>
</tbody>

<tbody>
</tbody>


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,214,861
Messages
6,121,971
Members
449,059
Latest member
oculus

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