Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Looking for code to separate one line of text into multiple lines in Excel

I often need to manipulate a string of data, sometimes many hundreds
of records, (up to 125 characters) into multiple columns - usually
five - for import into an application program. I've used split cell
into columns function of Excel 2003 but it still requires some manual
and semi-automated concatenation of resulting cells (up to 100+ per
record!).

I have an upper limit of 25 characters per new cell. I'd like to
split text into the multiple columns without cutting off a word in the
middle. e.g.:

Original text:
A long string that needs to be split into 5 adjacent cells of up to 25
characters and not splitting individual words

Ideally, resulting text should look something like this (each line
shown in separate row but actual result will be in same row, adhacent
columns):
A long string that needs
to be split into 5
adjacent cells of up to
25 characters and not
splitting individual word

Note that last character in last line ("s" in"words") was truncated
because it eceeded 25 characters.

Any help would be appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Looking for code to separate one line of text into multiple lines in Excel

On 12 Feb 2007 15:34:18 -0800, wrote:

I often need to manipulate a string of data, sometimes many hundreds
of records, (up to 125 characters) into multiple columns - usually
five - for import into an application program. I've used split cell
into columns function of Excel 2003 but it still requires some manual
and semi-automated concatenation of resulting cells (up to 100+ per
record!).

I have an upper limit of 25 characters per new cell. I'd like to
split text into the multiple columns without cutting off a word in the
middle. e.g.:

Original text:
A long string that needs to be split into 5 adjacent cells of up to 25
characters and not splitting individual words

Ideally, resulting text should look something like this (each line
shown in separate row but actual result will be in same row, adhacent
columns):
A long string that needs
to be split into 5
adjacent cells of up to
25 characters and not
splitting individual word

Note that last character in last line ("s" in"words") was truncated
because it eceeded 25 characters.

Any help would be appreciated.



You can do this using Regular Expressions, although the last one is tricky,
since you want to truncate at 25 characters rather than at a word break.

The easiest way to implement this, since your strings are less than 256
characters, would be to download and install Longre's free morefunc.xll add-in
from
http://xcell05.free.fr/ The add-in is easily distributable with the
workbook if that is an issue.

Then use these formulas (assuming your string is in A1:

B1: =TRIM(REGEX.MID($A1,".{1,25}\b",COLUMNS($A:A)))
Copy/drag across to E1.

F1: =LEFT(TRIM(MCONCAT(REGEX.MID($A1,".{1,25}\b",{5,6} ))),25)



--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
display 1 line of multiple worksheets into multiple lines on 1 wks Golf Nut Excel Worksheet Functions 1 October 5th 06 08:28 AM
Condensing Imported fixed-width text with multiple data lines to one Excel row [email protected] Excel Discussion (Misc queries) 1 August 5th 06 04:04 AM
How do I get multiple lines of text in a Excel cell? Tene Excel Discussion (Misc queries) 10 September 9th 05 10:23 PM
Code for Inserting Multiple lines Frantic Excel-er Excel Discussion (Misc queries) 0 June 17th 05 06:36 PM
Write code to insert multiple lines Frantic Excel-er Excel Discussion (Misc queries) 0 June 17th 05 12:13 AM


All times are GMT +1. The time now is 12:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"