A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Concatenating two variable fields into a static length text field



 
 
Thread Tools Display Modes
  #1  
Old April 17th, 2009, 05:06 PM posted to microsoft.public.excel.worksheet.functions
Young Programmer Lad
external usenet poster
 
Posts: 2
Default Concatenating two variable fields into a static length text field

I have a spreadsheet with two columns of variable length text that I want to
concatenate into a static length text field. The first column can be
anywhere from 1 to 28 characters and the second is only 2 characters. How do
I concatenate the field and space fill any columns so that the net result is
a column with a static 30 characters and the second column is always in
position 29 and 30? Here is a sample of the data:

Column 1 Column 2 Desired result
A805605252 01 A805605252 01
2009/32-1980 02 2009/32-1980 02
2009/163-1980 01 2009/163-1980 01
2009/167-1980 03 2009/167-1980 03
2009/302-1980 01 2009/302-1980 01
2009/303-1980 01 2009/303-1980 01
259-96-21 06 259-96-21 06

If you use concatenate, the function trims the spaces at the end. It can be
done with performing a length check and adding the appropriate number of
spaces, but a separate else if needs to be created for each length. This can
be cumbersome. I know I can save the file in a formated text space delimited
(.prn) and re-import it to get the result, but would rather do so in a
function.

Any help would be appreciated.
  #2  
Old April 17th, 2009, 05:11 PM posted to microsoft.public.excel.worksheet.functions
Bob Umlas[_3_]
external usenet poster
 
Posts: 197
Default Concatenating two variable fields into a static length text field

=LEFT(A1&REPT(" ",28),28)&B1
and fill down

"Young Programmer Lad" wrote
in message ...
I have a spreadsheet with two columns of variable length text that I want
to
concatenate into a static length text field. The first column can be
anywhere from 1 to 28 characters and the second is only 2 characters. How
do
I concatenate the field and space fill any columns so that the net result
is
a column with a static 30 characters and the second column is always in
position 29 and 30? Here is a sample of the data:

Column 1 Column 2 Desired result
A805605252 01 A805605252 01
2009/32-1980 02 2009/32-1980 02
2009/163-1980 01 2009/163-1980 01
2009/167-1980 03 2009/167-1980 03
2009/302-1980 01 2009/302-1980 01
2009/303-1980 01 2009/303-1980 01
259-96-21 06 259-96-21 06

If you use concatenate, the function trims the spaces at the end. It can
be
done with performing a length check and adding the appropriate number of
spaces, but a separate else if needs to be created for each length. This
can
be cumbersome. I know I can save the file in a formated text space
delimited
(.prn) and re-import it to get the result, but would rather do so in a
function.

Any help would be appreciated.



  #3  
Old April 17th, 2009, 05:39 PM posted to microsoft.public.excel.worksheet.functions
Young Programmer Lad
external usenet poster
 
Posts: 2
Default Concatenating two variable fields into a static length text fi

Works like a charm. Thanks!

"Bob Umlas" wrote:

=LEFT(A1&REPT(" ",28),28)&B1
and fill down

"Young Programmer Lad" wrote
in message ...
I have a spreadsheet with two columns of variable length text that I want
to
concatenate into a static length text field. The first column can be
anywhere from 1 to 28 characters and the second is only 2 characters. How
do
I concatenate the field and space fill any columns so that the net result
is
a column with a static 30 characters and the second column is always in
position 29 and 30? Here is a sample of the data:

Column 1 Column 2 Desired result
A805605252 01 A805605252 01
2009/32-1980 02 2009/32-1980 02
2009/163-1980 01 2009/163-1980 01
2009/167-1980 03 2009/167-1980 03
2009/302-1980 01 2009/302-1980 01
2009/303-1980 01 2009/303-1980 01
259-96-21 06 259-96-21 06

If you use concatenate, the function trims the spaces at the end. It can
be
done with performing a length check and adding the appropriate number of
spaces, but a separate else if needs to be created for each length. This
can
be cumbersome. I know I can save the file in a formated text space
delimited
(.prn) and re-import it to get the result, but would rather do so in a
function.

Any help would be appreciated.




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:48 AM.


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