Split a Column into 2, use a character limit that does not cut words in half.

vishesh10667

New Member
Joined
Nov 26, 2019
Messages
18
Office Version
  1. 2007
Platform
  1. Windows
Title says it all.

I have huge columns of data that can only be 30 characters long. I want to use a formula to split the column into two. The original column will have a character limit of 30, and should not cut words in half. If the Length will be more than 30 while including the entire last word of the cell, that word should be the first displayed in adjacent cell in the 2nd column.

The 2nd column should also be 30 characters long. And rest in 3 column


I usually use a Text to Columns method, but dont know how to make it not cut off the words. Any ideas?

Thanks in advance
 
Hard to read much in that image but it looks like the code has processed some of the rows. Can you post the text of what is in the next row in column A (looks like that might be row 9?) as I assume there must be something different/unusual about what is in that cell.

It is showing a runtime error 9 that the subscript is out of range
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
It is showing a runtime error 9 that the subscript is out of range
Yes, I could read that much before. What is the answer to the question I asked about it?
.. it looks like the code has processed some of the rows.
Can you post the text of what is in the next row in column A (looks like that might be row 9?) as I assume there must be something different/unusual about what is in that cell.
 
Upvote 0
Yes, I could read that much before. What is the answer to the question I asked about it?


Binoj bhavan,EdavakodeSreekariyam p.o

Some of the address there is no space in between, i think because of this it is not capturing
 
Upvote 0
I have tried it is not working.
Is it the same "not working" as in post 15?
If so, try copying the formulas from here instead.
For cell B1:
Code:
=IF(LEN(A1)<=30,A1,LEFT(A1,FIND("#",SUBSTITUTE(LEFT(A1,31)," ","#",LEN(LEFT(A1,31))-LEN(SUBSTITUTE(LEFT(A1,31)," ",""))))-1))
For cell C1:
Code:
=IF(LEN(A1)<=61,REPLACE(A1,1,LEN(B1)+1,""),LEFT(REPLACE(A1,1,LEN(B1)+1,""),FIND("#",SUBSTITUTE(LEFT(REPLACE(A1,1,LEN(B1)+1,""),31)," ","#",LEN(LEFT(REPLACE(A1,1,LEN(B1)+1,""),31))-LEN(SUBSTITUTE(LEFT(REPLACE(A1,1,LEN(B1)+1,""),31)," ",""))))-1))
For cell D1:
Code:
=TRIM(SUBSTITUTE(A1,TRIM(B1&" "&C1),""))

If it a different "not working" then please explain in what way it is "not working"


How did the macro go when you made the change in post 27?
 
Upvote 0
=IF(LEN(A1)<=61,REPLACE(A1,1,LEN(B1)+1,""),LEFT(REPLACE(A1,1,LEN(B1)+1,""),FIND("#",SUBSTITUTE(LEFT(REPLACE(A1,1,LEN(B1)+1,""),31)," ","#",LEN(LEFT(REPLACE(A1,1,LEN(B1)+1,""),31))-LEN(SUBSTITUTE(LEFT(REPLACE(A1,1,LEN(B1)+1,""),31)," ",""))))-1))

It is just showing the below error
 

Attachments

  • Formula Error.JPG
    Formula Error.JPG
    12.4 KB · Views: 27
Upvote 0
It is just showing the below error
Hmm, you must be using a very old Excel version. You really should state that in any questions you ask as helpers will generally expect something newer than that. ;)
 
Upvote 0

Forum statistics

Threads
1,216,179
Messages
6,129,333
Members
449,502
Latest member
TSH8125

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