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.

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

<tbody>
</tbody>
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
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,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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