Etract numbers from a string of 13 digits into 5 separate cells

Kazdima

Board Regular
Joined
Oct 15, 2010
Messages
226
Hello,
i need do extract digits from One cell into 5 separate.

<colgroup><col style="mso-width-source:userset;mso-width-alt:2706;width:56pt" width="74"> <col style="width:48pt" width="64" span="4"> <col style="mso-width-source:userset;mso-width-alt:4352;width:89pt" width="119"> </colgroup><tbody>
[TD="class: xl69, width: 449, colspan: 6"][/TD]

[TD="class: xl72"]A[/TD]
[TD="class: xl73"]B[/TD]
[TD="class: xl73"]C[/TD]
[TD="class: xl73"]D[/TD]
[TD="class: xl73"]E [/TD]
[TD="class: xl74"]F[/TD]

[TD="class: xl75"]2digits[/TD]
[TD="class: xl66"]3digits[/TD]
[TD="class: xl66"]1digit[/TD]
[TD="class: xl66"]3digits[/TD]
[TD="class: xl66"]4digits[/TD]
[TD="class: xl76"]13digits string[/TD]

[TD="class: xl77"]01[/TD]
[TD="class: xl68"]259[/TD]
[TD="class: xl68"]6[/TD]
[TD="class: xl68"]310[/TD]
[TD="class: xl68"]7510[/TD]
[TD="class: xl78"]0125963107510[/TD]

[TD="class: xl79"] [/TD]

[TD="class: xl80"] [/TD]

[TD="class: xl81, colspan: 6"]Note: "Zero" can be in any part of new strings. Not to lose it.[/TD]

</tbody>

Thank you for a help with a formula, and/or Macro.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi,

Will this work for you:


Excel 2010
ABCDEF
12digits3digits1digit3digits4digits13digits string
201259631075100125963107510
Sheet14
Cell Formulas
RangeFormula
A2=LEFT(F2,2)
B2=MID(F2,3,3)
C2=MID(F2,6,1)
D2=MID(F2,7,3)
E2=RIGHT(F2,4)
 
Upvote 0
Here's an alternative where the number of digits you want to extract is in row 1.

Excel Workbook
ABCDEF
123134
201259631075100125963107510
Sheet3
 
Upvote 0
And if OP can add a Blank column in front, one formula can do all five:


Excel 2010
ABCDEFG
5digitsdigitsdigitsdigitsdigits
62313413digits string
701259631075100125963107510
Sheet14
Cell Formulas
RangeFormula
B7=MID($G7,SUM($A6:A6,1),B6)


B7 formula copied across to F7
 
Last edited:
Upvote 0
And if OP can add a Blank column in front, one formula can do all five:


Excel 2010
ABCDEFG
5digitsdigitsdigitsdigitsdigits
62313413digits string
701259631075100125963107510
Sheet14
Cell Formulas
RangeFormula
B7=MID($G7,SUM($A6:A6,1),B6)


B7 formula copied across to F7
If your worksheet is listing the number of digits per cell as jtakw has assumed above, then use his formula. However, if you are not listing the digit count on the worksheet directly, then you can use the following single formula. With your number in cell F2, put this formula in cell A2 and copy it across to cell E2...

=MID($F2,LOOKUP(COLUMNS($A:A),{1,2,3,4,5},{1,3,6,7,10}),LOOKUP(COLUMNS($A:A),{1,2,3,4,5},{2,3,1,3,4}))
 
Upvote 0
If your worksheet is listing the number of digits per cell as jtakw has assumed above, then use his formula. However, if you are not listing the digit count on the worksheet directly, then you can use the following single formula. With your number in cell F2, put this formula in cell A2 and copy it across to cell E2...

=MID($F2,LOOKUP(COLUMNS($A:A),{1,2,3,4,5},{1,3,6,7,10}),LOOKUP(COLUMNS($A:A),{1,2,3,4,5},{2,3,1,3,4}))
This is probably a more straightforward formula to use...

=MID($F2,CHOOSE(COLUMNS($A:A),1,3,6,7,10),CHOOSE(COLUMNS($A:A),2,3,1,3,4))
 
  • Like
Reactions: ISY
Upvote 0
Hi!

Another way (with JoeMo's layout). In A2 and copy to the right

=LEFT(REPLACE($F2,1,SUM($A1:$E1)-SUM(A1:$E1),""),A1)

Markmzz
 
Last edited:
Upvote 0
. formula, and/or Macro.
Assuming data starting in F2 you could also try this 1-line macro.
Code:
Sub TTC()
  Range("F2", Range("F" & Rows.Count).End(xlUp)).TextToColumns Destination:=Range("A2"), DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), Array(2, 2), Array(5, 2), Array(6, 2), Array(9, 2))
End Sub
 
Upvote 0

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