Splitting text in cells based on criteria.

Wamhoi

New Member
Joined
Mar 4, 2011
Messages
48
Hi all,

I'm trying to break up text in excel based on certain criteria and would prefer using a formula.

Criteria one: Must be 35 characters or less in length
Criteria two: Must include full words

So for example:

Cell A1: Sally bought a new purse

End Result:
Cell A1: Sally bought a new purse
Cell B1: Sally bought a (assume 35 characters)
Cell C1: new purse (assume 35 characters)

As mentioned earlier the only caveot is that it cannot break individual words IE: "Sally bought a ne"
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Will you have cells with more than 70 characters?
 
Upvote 0
So, for instance, if a cell contains sixty characters; the first cell should return 35 (assuming it breaks the words appropriately) and the second should return 25. Correct?
 
Upvote 0
This works for your first cell.
=TRIM(LEFT(SUBSTITUTE(A1," ",REPT(" ",100)),(100*(35-LEN(SUBSTITUTE(LEFT(A1,35)," ",""))))))
 
Upvote 0
Try:

First cell (array formula, confirmed with CTRL+SHIFT+ENTER, not just ENTER):
Code:
=LEFT(A1,MATCH(2,1/(MID(A1,ROW(INDIRECT("1:36")),1)=" "))-1)
Second cell (array formula, confirmed with CTRL+SHIFT+ENTER, not just ENTER):
Code:
=IF(LEN(A1)-LEN(B1)<=35,MID(A1,LEN(B1)+2,LEN(A1)),MID(A1,LEN(B1)+2,MATCH(2,1/(MID(A1,ROW(INDIRECT(LEN(B1)+2&":"&71)),1)=" "))-1))
Third cell (non-array formula):
Code:
=IF(LEN(A1)>70,MID(A1,LEN(B1)+LEN(C1)+3,LEN(A1)),"")
 
Last edited:
Upvote 0
I was following along this thread as it is something that would help me as well. However our rows must contain no more than 61 characters.

I changed the 35 to 61 in the first formula (for Cell B1) and it worked perfectly. However in the second formula (for C1), it returns the next word only after the words in Cell B1, instead of the next 61 characters. Is the second formula correct? Or did my changing it to 61 characters mess it up?

Thanks for your help.

David
 
Upvote 0
David, please don't jump into a thread requesting something different than the original poster, especially when that poster hasn't even gotten back to us whether it worked or not.

However...

In the first formula make two changes. I added an IF function to check if the original cell is less than 61 characters and if so, just return the original cell value. This should be done in my previous thread, which hopefully I can do in a minute.
Code:
=IF(LEN(A1)<=61,A1,LEFT(A1,MATCH(2,1/(MID(A1,ROW(INDIRECT("1:62")),1)=" "))-1))
In the second formula change "<=35" to "<=61" (near the beginning), and change "&71" to "&123" (near the end).

In the third formula change ">70" to ">122".

Can't edit my previous post with formulas, so to limit the first cell to 35 use this updated formula:
Code:
=IF(LEN(A1)<=35,A1,LEFT(A1,MATCH(2,1/(MID(A1,ROW(INDIRECT("1:36")),1)=" "))-1))
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,147
Members
449,098
Latest member
Doanvanhieu

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