Extracting certain characters from a long string

  • Thread starter Stan in South Africa
  • Start date
S

Stan in South Africa

Win XP Pro, Office 2003
I have received a text (txt) file with instructions to 'convert this to
excel'.
Each of the 765 lines of the text file is 315 characters long and consists
of data about certain insurance policies.
I have counted the characters as follows (applies to all lines):
Policy number = Characters 1 to 15
Title = Characters 17 to 31
Last Name = Characters 32 to 70
and so on.
I have copied and pasted the data into excel and now have a 'A1' (Down to
A765) cell with 315 characters in it, some text, some numbers. There are now
765 rows in the file.
How do I extract (to a new worksheet, in the same workbook)
Characters 1 to 15 to A1
Characters 17 to 31 to B1
Characters 32 to 70 to C1
and so on?
Thanks in advance.
 
P

Peo Sjoblom

=LEFT(TRIM(A1),15)
=MID(TRIM(A1),17,15)
=MID(TRIM(A1),32,39)

and so on

then select all cells with formulas and grab the lower right corner of the
rightmost cell
and copy down 765 rows


--


Regards,


Peo Sjoblom
 
R

Reitanos

If you use the File/Open command in Excel it will bring up the Text
Import Wizard that will allow you to select "Fixed Width." You can
then define the columns on the 2nd step by dragging with your mouse.
And you can set each data type on the 3rd page of the wizard.
 
G

Glenn

Stan said:
Win XP Pro, Office 2003
I have received a text (txt) file with instructions to 'convert this to
excel'.
Each of the 765 lines of the text file is 315 characters long and consists
of data about certain insurance policies.
I have counted the characters as follows (applies to all lines):
Policy number = Characters 1 to 15
Title = Characters 17 to 31
Last Name = Characters 32 to 70
and so on.
I have copied and pasted the data into excel and now have a 'A1' (Down to
A765) cell with 315 characters in it, some text, some numbers. There are now
765 rows in the file.
How do I extract (to a new worksheet, in the same workbook)
Characters 1 to 15 to A1
Characters 17 to 31 to B1
Characters 32 to 70 to C1
and so on?
Thanks in advance.


Select column A.

Data menu / Text to Columns / Fixed Width
 
S

Stan in South Africa

Thanks for speedy answer!
Peo Sjoblom said:
=LEFT(TRIM(A1),15)
=MID(TRIM(A1),17,15)
=MID(TRIM(A1),32,39)

and so on

then select all cells with formulas and grab the lower right corner of the
rightmost cell
and copy down 765 rows


--


Regards,


Peo Sjoblom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top