How to Separate Parts of Text from One Cell into Multiple

ikedawood

New Member
Joined
Feb 7, 2019
Messages
2
Hello,

I have a string of text in a cell that I need to separate into multiple cells, Text to Columns will work however I need a formula to do this as I don't want to have to break this out every time I refresh the data.

I don't think LEFT, RIGHT, or MID functions will work since the number of characters may vary. A2 reads: A-Frames (88), Baselines (2), Courtsides (3), Dasherboards (14), Home Plate (5), Small Home Plate (6), Other (27)

The text, parentheses, and commas will remain the same on each row in column A. However, the number next to each will vary. I need a formula in cells B2:H2 that will pull in the appropriate data as noted below.

[TABLE="class: grid, width: 1200"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[TD="align: center"]G[/TD]
[TD="align: center"]H[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD]Types and Quantity[/TD]
[TD]A-Frames[/TD]
[TD]Baselines[/TD]
[TD]Courtsides[/TD]
[TD]Dasherboards[/TD]
[TD]Home Plate[/TD]
[TD]Small Home Plate[/TD]
[TD]Other[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD]A-Frames (88), Baselines (2), Courtsides (3), Dasherboards (14), Home Plate (5), Small Home Plate (6), Other (27)[/TD]
[TD]88[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]14[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]27[/TD]
[/TR]
</tbody>[/TABLE]
 

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
Hi & welcome to MrExcel.
If you're interested in a UDF how about
Code:
Function Mysplit(cl As Range, itm As Long) As Long
   Dim Sp As Variant
   Sp = Split(cl, "(")
   Mysplit = Split(Sp(itm), ")")(0)
End Function
Used like =Mysplit($A2,COLUMN(A1))
 
Upvote 0
Hi,

Use B2 formula copied across, results are Text.
Use B3 formula copied across, results converted to Real Numbers:


Book1
ABCDEFGH
1Types and QuantityA-FramesBaselinesCourtsidesDasherboardsHome PlateSmall Home PlateOther
2A-Frames (88), Baselines (2), Courtsides (3), Dasherboards (14), Home Plate (5), Small Home Plate (6), Other (27)8823145627
38823145627
Sheet553
Cell Formulas
RangeFormula
B2=TRIM(MID(SUBSTITUTE(SUBSTITUTE($A2&",","),","("),"(",REPT(" ",100)),(COLUMNS($B2:B2)*2-1)*100,100))
B3=MID(SUBSTITUTE(SUBSTITUTE($A2&",","),","("),"(",REPT(" ",100)),(COLUMNS($B2:B2)*2-1)*100,100)+0
 
Last edited:
Upvote 0
jtakw, that works perfectly!!! Thanks so much for the help on that.

If down the road I was to add a new option, say after "Other (###)" I was to add an additional ", TEXT (###)". How would I alter the formula when adding a column I? Again the common, parenthesis, and text would remain consistent, just the number would change.
 
Upvote 0
You're welcome, welcome to the forum.

My formula will actually accommodate as Many extractions as needed, the Only part of the formula that needs changing is the number 100, due to the longer original text string in A2, for now we'll change it to 255, which should be plenty for your purposes:


Book1
ABCDEFGHIJK
1Types and QuantityA-FramesBaselinesCourtsidesDasherboardsHome PlateSmall Home PlateOther
2A-Frames (88), Baselines (2), Courtsides (3), Dasherboards (14), Home Plate (5), Small Home Plate (6), Other (27), Text(123), More Text (456), Even More Text (789)8823145627123456789
38823145627123456789
Sheet553
Cell Formulas
RangeFormula
B2=TRIM(MID(SUBSTITUTE(SUBSTITUTE($A2&",","),","("),"(",REPT(" ",255)),(COLUMNS($B2:B2)*2-1)*255,255))
B3=MID(SUBSTITUTE(SUBSTITUTE($A2&",","),","("),"(",REPT(" ",255)),(COLUMNS($B2:B2)*2-1)*255,255)+0


The formula will extract correctly as long as your original text string does not exceed 250+ characters, if it Does, then you can change all instances of 255 to a higher number or LEN(A2)
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,314
Members
452,634
Latest member
cpostell

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