Text To Columns with odd items in brackets

mad3

Board Regular
Joined
Sep 15, 2009
Messages
130
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have two columns with 9 or more single digits numbers that are text. The issue with simple text to columns is that if any of the 9 numbers is a double digit number it looks like this in the cell...

Q​
R​
0001010(11)0400100000
0000001000000000200
101010100000000(10)000


I want to extract each individual number in column Q to separate columns; same with column R. to a separate column to study the totals, but have an issue every time it runs into the odd ball double digit number which is always like this (10)

If it helps, these are line scores from baseball games, but have a number of them with double digit scoring in a single inning.
any ideas on how to extract each number including the double digit numbers?

Thanks, Mike in Cali...
 
Nice one Felix! Here a technique (rebuild your formula) where you don't need the name manager for recursive Lambda's.

Book1
ABCDEFGHIJKLM
10001010(11)00001010110
200000010000000001000
310101010001010101000
4400100000400100000
5000000200000000200
600000(10)0000000010000
701234567890123456789
8(10)(11)(12)(13)(14)(15)(16)(17)(18)(19)10111213141516171819
9(20)(21)(22)(23)(24)(25)(26)(27)(28)(29)20212223242526272829
10(30)(31)(32)(33)(34)(35)(36)(37)(38)(39)30313233343536373839
11(40)(41)(42)(43)(44)(45)(46)(47)(48)(49)40414243444546474849
12(50)(51)(52)(53)(54)(55)(56)(57)(58)(59)50515253545556575859
13(60)(61)(62)(63)(64)(65)(66)(67)(68)(69)60616263646566676869
14(70)(71)(72)(73)(74)(75)(76)(77)(78)(79)70717273747576777879
15(80)(81)(82)(83)(84)(85)(86)(87)(88)(89)80818283848586878889
16(90)(91)(92)(93)(94)(95)(96)(97)(98)(99)90919293949596979899
Sheet1
Cell Formulas
RangeFormula
B1:J1,B7:K16,B4:J6,B2:K3B1=LET(R,LAMBDA(R,str,i,IF(i<100,R(R,SUBSTITUTE(str,"("&i&")",CHAR(48+i)),i+1),CODE(MID(str,SEQUENCE(,LEN(str)),1))-48)),R(R,A1,10))
Dynamic array formulas.
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Yes, you are right. I wanted to extract q and place to the right. What I was amiss about was how many columns I had vacated for the formula to work. My bad. I will follow your suggestion and change sequence to number of vacated columns. Thank you!
Hi Rick,

While formula works for home team,
I adjusted the sequence to 22 ( number of vacant columns to right of (visiting team) column formula is checking and it still didn't work.
 
Upvote 0
Hi Rick,

While formula works for home team,
I adjusted the sequence to 22 ( number of vacant columns to right of (visiting team) column formula is checking and it still didn't work.
Can you give me some specific examples that did not work and tell me exactly what did not work so I can test the formula against actual data and then know where to look for the problem.
 
Upvote 0
Can you give me some specific examples that did not work and tell me exactly what did not work so I can test the formula against actual data and then know where to look for the problem.
Here is a snapshot of a few selected rows from one of sheets. The H-LINESCORE works fine. No other data to right of column where formula is.
The V-LINESCORE would not work when placing the formula in cell U4 or any of the cells below that one. This same scenario happens on all spreadsheets for V-LINESCORE.
V-LINESCORE123456789101112131415161718192021222324252627282930H-LINESCORE12345678910111213
10000000000121040x00121040x
0001000000000000(10)00001000001000001
010203100000011020000011020
00001100100010510x00010510x
00130000000011021x00011021x
200002000110000(30)000010000300000
001012141000103000000103000
00000000020112002x20112002x
210010100000100020200100000002020010000
00000000000000100x00000100x
00000101000011100x00011100x
010100010000100001000100001
004100000000000010000000010
00100000000204101x00204101x
00100001002000010x02000010x
200000020210000012001000001200
00000020002100000x02100000x

1701894940584.png
 
Upvote 0
I must be missing something since as far as I can see the formula from post 4 (though certainly not the shortest formula suggested) works with all the scenarios posted.
Here it is again with the latest layout/sample data & showing no issues where there is other data to the right (provided there are sufficient empty columns to house the results)

mad3.xlsm
TUVWXYZAAABACADAEAFAGAHAXAYAZBABBBCBDBEBFBGBHBIBJBKBL
3V-LINESCORE123456789101112131430H-LINESCORE12345678910111213
410000000010000000000121040x00121040x
5000100000000001000000000000(10)00001000001000001
6010203100010203100000011020000011020
700001100100001100100010510x00010510x
800130000000130000000011021x00011021x
92000020001200002000110000(30)000010000300000
10001012141001012141000103000000103000
1100000000000000000020112002x20112002x
122100101000001210010100000100020200100000002020010000
1300000000000000000000000100x00000100x
1400000101000000101000011100x00011100x
15010100010010100010000100001000100001
16004100000004100000000000010000000010
1700100000000100000000204101x00204101x
1800100001000100001002000010x02000010x
192000000202200000020210000012001000001200
2000000020000000020002100000x02100000x
Sheet1
Cell Formulas
RangeFormula
U4:AC4,AZ20:BH20,AZ19:BI19,AZ13:BH18,AZ12:BL12,AZ10:BH11,AZ9:BI9,AZ6:BH8,AZ5:BJ5,AZ4:BH4,U20:AC20,U19:AD19,U13:AC18,U12:AG12,U10:AC11,U9:AD9,U6:AC8,U5:AE5U4=LET(ts,TEXTSPLIT(T4,{"(",")"}),TEXTSPLIT(TEXTJOIN(" ",1,BYCOL(TEXT(SEQUENCE(,COLUMNS(ts)),"00")&ts,LAMBDA(c,IF(ISODD(LEFT(c,2)+0),TEXTJOIN(" ",1,MID(c,SEQUENCE(,99,3),1)),MID(c,3,2)))))," "))
Dynamic array formulas.
 
Upvote 0
I must be missing something since as far as I can see the formula from post 4 (though certainly not the shortest formula suggested) works with all the scenarios posted.
Here it is again with the latest layout/sample data & showing no issues where there is other data to the right (provided there are sufficient empty columns to house the results)

mad3.xlsm
TUVWXYZAAABACADAEAFAGAHAXAYAZBABBBCBDBEBFBGBHBIBJBKBL
3V-LINESCORE123456789101112131430H-LINESCORE12345678910111213
410000000010000000000121040x00121040x
5000100000000001000000000000(10)00001000001000001
6010203100010203100000011020000011020
700001100100001100100010510x00010510x
800130000000130000000011021x00011021x
92000020001200002000110000(30)000010000300000
10001012141001012141000103000000103000
1100000000000000000020112002x20112002x
122100101000001210010100000100020200100000002020010000
1300000000000000000000000100x00000100x
1400000101000000101000011100x00011100x
15010100010010100010000100001000100001
16004100000004100000000000010000000010
1700100000000100000000204101x00204101x
1800100001000100001002000010x02000010x
192000000202200000020210000012001000001200
2000000020000000020002100000x02100000x
Sheet1
Cell Formulas
RangeFormula
U4:AC4,AZ20:BH20,AZ19:BI19,AZ13:BH18,AZ12:BL12,AZ10:BH11,AZ9:BI9,AZ6:BH8,AZ5:BJ5,AZ4:BH4,U20:AC20,U19:AD19,U13:AC18,U12:AG12,U10:AC11,U9:AD9,U6:AC8,U5:AE5U4=LET(ts,TEXTSPLIT(T4,{"(",")"}),TEXTSPLIT(TEXTJOIN(" ",1,BYCOL(TEXT(SEQUENCE(,COLUMNS(ts)),"00")&ts,LAMBDA(c,IF(ISODD(LEFT(c,2)+0),TEXTJOIN(" ",1,MID(c,SEQUENCE(,99,3),1)),MID(c,3,2)))))," "))
Dynamic array formulas.
I see you are getting results, but when I cut and paste the formula into cell U4, all I get is the formula, no result. I'm using excel 365 Enterprise so it should work based on result you are achieving. I don't know what is wrong.
 
Upvote 0
when I cut and paste the formula into cell U4, all I get is the formula,
Sounds like U4 is formatted as 'Text'. Change the U4 format to 'General' and re-confirm the formula in that cell.
 
Upvote 0
I must be missing something since as far as I can see the formula from post 4 (though certainly not the shortest formula suggested) works with all the scenarios posted.
Here it is again with the latest layout/sample data & showing no issues where there is other data to the right (provided there are sufficient empty columns to house the results)

mad3.xlsm
TUVWXYZAAABACADAEAFAGAHAXAYAZBABBBCBDBEBFBGBHBIBJBKBL
3V-LINESCORE123456789101112131430H-LINESCORE12345678910111213
410000000010000000000121040x00121040x
5000100000000001000000000000(10)00001000001000001
6010203100010203100000011020000011020
700001100100001100100010510x00010510x
800130000000130000000011021x00011021x
92000020001200002000110000(30)000010000300000
10001012141001012141000103000000103000
1100000000000000000020112002x20112002x
122100101000001210010100000100020200100000002020010000
1300000000000000000000000100x00000100x
1400000101000000101000011100x00011100x
15010100010010100010000100001000100001
16004100000004100000000000010000000010
1700100000000100000000204101x00204101x
1800100001000100001002000010x02000010x
192000000202200000020210000012001000001200
2000000020000000020002100000x02100000x
Sheet1
Cell Formulas
RangeFormula
U4:AC4,AZ20:BH20,AZ19:BI19,AZ13:BH18,AZ12:BL12,AZ10:BH11,AZ9:BI9,AZ6:BH8,AZ5:BJ5,AZ4:BH4,U20:AC20,U19:AD19,U13:AC18,U12:AG12,U10:AC11,U9:AD9,U6:AC8,U5:AE5U4=LET(ts,TEXTSPLIT(T4,{"(",")"}),TEXTSPLIT(TEXTJOIN(" ",1,BYCOL(TEXT(SEQUENCE(,COLUMNS(ts)),"00")&ts,LAMBDA(c,IF(ISODD(LEFT(c,2)+0),TEXTJOIN(" ",1,MID(c,SEQUENCE(,99,3),1)),MID(c,3,2)))))," "))
Dynamic array formulas.
Amazing!
When I imported the file from net, I only brought over two columns as text, the V-linescore and H-linescore. However, I added the columns for the line score arrays to spill into. I managed to insert columns between the two Text formatted columns. Thus formatting the inserted columns as text. Ugh!
Formula now works just fine. Rick's and the other formulas work as well. Thanks so much!
Another lesson learned from the brain trust of this great program.
 
Upvote 0
Here is a snapshot of a few selected rows from one of sheets. The H-LINESCORE works fine. No other data to right of column where formula is.
The V-LINESCORE would not work when placing the formula in cell U4 or any of the cells below that one. This same scenario happens on all spreadsheets for V-LINESCORE.
V-LINESCORE123456789101112131415161718192021222324252627282930H-LINESCORE12345678910111213
10000000000121040x00121040x
0001000000000000(10)00001000001000001
010203100000011020000011020
00001100100010510x00010510x
00130000000011021x00011021x
200002000110000(30)000010000300000
001012141000103000000103000
00000000020112002x20112002x
210010100000100020200100000002020010000
00000000000000100x00000100x
00000101000011100x00011100x
010100010000100001000100001
004100000000000010000000010
00100000000204101x00204101x
00100001002000010x02000010x
200000020210000012001000001200
00000020002100000x02100000x

View attachment 103089
Formula works just fine!
I managed to insert columns between linescores, thus Formatting new columns as text. Thanks so much for the help. And the suggestion to update profile. I need to get on forum regularly to keep up the learning from you gentlemen that are the brains of this great program!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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