Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Custom Fields with spaces

Hi,
The easiest way to explain my dilemma is by example. I need a custom
field that is always thirty character spaces long no matter how long
the text is. So for example, lets say the word is PIZZA which is 5
characters, I would need 25 blank spaces afterwards to get to 30
characters in total. Does anybody know what this would look like?
I've tried to use the _ but that doesn't seem to work. Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Custom Fields with spaces

one method
if your text is in A1
=a1&Rept(" ",30-len(A1))

" wrote:

Hi,
The easiest way to explain my dilemma is by example. I need a custom
field that is always thirty character spaces long no matter how long
the text is. So for example, lets say the word is PIZZA which is 5
characters, I would need 25 blank spaces afterwards to get to 30
characters in total. Does anybody know what this would look like?
I've tried to use the _ but that doesn't seem to work. Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel
external usenet poster
 
Posts: 6
Default Custom Fields with spaces

On Jul 13, 11:46 am, bj wrote:
one method
if your text is in A1
=a1&Rept(" ",30-len(A1))



" wrote:
Hi,
The easiest way to explain my dilemma is by example. I need a custom
field that is always thirty character spaces long no matter how long
the text is. So for example, lets say the word is PIZZA which is 5
characters, I would need 25 blank spaces afterwards to get to 30
characters in total. Does anybody know what this would look like?
I've tried to use the _ but that doesn't seem to work. Thanks.- Hide quoted text -


- Show quoted text -


Perfect! Thanks~ :)

  #4   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Custom Fields with spaces

Plum-cool BJ, Plum-cool...........

Vaya con Dios,
Chuck, CABGx3



"bj" wrote:

one method
if your text is in A1
=a1&Rept(" ",30-len(A1))

" wrote:

Hi,
The easiest way to explain my dilemma is by example. I need a custom
field that is always thirty character spaces long no matter how long
the text is. So for example, lets say the word is PIZZA which is 5
characters, I would need 25 blank spaces afterwards to get to 30
characters in total. Does anybody know what this would look like?
I've tried to use the _ but that doesn't seem to work. Thanks.


  #5   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Custom Fields with spaces

Suppose A1 has the text you want to format, then use this formula in B1:
=A1&REPT(CHAR(32),30-LEN(A1))

wrote in message
oups.com...
Hi,
The easiest way to explain my dilemma is by example. I need a custom
field that is always thirty character spaces long no matter how long
the text is. So for example, lets say the word is PIZZA which is 5
characters, I would need 25 blank spaces afterwards to get to 30
characters in total. Does anybody know what this would look like?
I've tried to use the _ but that doesn't seem to work. Thanks.





  #7   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default Custom Fields with spaces

The easiest way to explain my dilemma is by example. I need a custom
field that is always thirty character spaces long no matter how long
the text is. So for example, lets say the word is PIZZA which is 5
characters, I would need 25 blank spaces afterwards to get to 30
characters in total. Does anybody know what this would look like?
I've tried to use the _ but that doesn't seem to work. Thanks.


What did you want to happen if the user typed in more than 30 characters?
The formulas posted by 'bj' and 'a7n9' will error out with a #VALUE error;
the formula posted by Dave will truncate the entry at the 30th character;
and the following formula will preserve all characters (thus returning a
value longer than 30 characters for a long entry).

=REPLACE(REPT(" ",30),1,LEN(A1),A1)

Rick

  #8   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Custom Fields with spaces

Good point, but in this case, it looks like the OP actually wants it
truncated--well if "always thirty character spaces long no matter how long the
text is" actually means that.

"Rick Rothstein (MVP - VB)" wrote:

The easiest way to explain my dilemma is by example. I need a custom
field that is always thirty character spaces long no matter how long
the text is. So for example, lets say the word is PIZZA which is 5
characters, I would need 25 blank spaces afterwards to get to 30
characters in total. Does anybody know what this would look like?
I've tried to use the _ but that doesn't seem to work. Thanks.


What did you want to happen if the user typed in more than 30 characters?
The formulas posted by 'bj' and 'a7n9' will error out with a #VALUE error;
the formula posted by Dave will truncate the entry at the 30th character;
and the following formula will preserve all characters (thus returning a
value longer than 30 characters for a long entry).

=REPLACE(REPT(" ",30),1,LEN(A1),A1)

Rick


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default Custom Fields with spaces

Good point, but in this case, it looks like the OP actually wants it
truncated--well if "always thirty character spaces long no matter
how long the text is" actually means that.


Oh, I agree. I just wanted to make sure the OP was alerted to the different
results the methods produced for over 30 characters entered. That way, if
the possibility of this situation never occurred to the OP, he/she would
have a choice of how to account for it.

Rick

  #10   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Custom Fields with spaces

I never remember =replace(). I would have used an =if(len()) approach.

I guess I was just being argumentative on a Saturday morning <bg.

http://wordnet.princeton.edu/perl/webwn?s=curmudgeon



"Rick Rothstein (MVP - VB)" wrote:

Good point, but in this case, it looks like the OP actually wants it
truncated--well if "always thirty character spaces long no matter
how long the text is" actually means that.


Oh, I agree. I just wanted to make sure the OP was alerted to the different
results the methods produced for over 30 characters entered. That way, if
the possibility of this situation never occurred to the OP, he/she would
have a choice of how to account for it.

Rick


--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 1,231
Default Custom Fields with spaces

"Rick Rothstein (MVP - VB)" wrote...
....
=REPLACE(REPT(" ",30),1,LEN(A1),A1)


Wouldn't

=LEFT(A1&REPT(" ",30),30)

be simpler?


  #12   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default Custom Fields with spaces

=REPLACE(REPT(" ",30),1,LEN(A1),A1)

Wouldn't

=LEFT(A1&REPT(" ",30),30)


Well, that is the same formula that Dave posted... I posted my formula in
order to provide the OP with a choice in case the user enters more than 30
characters. Your (and Dave's) formula will truncate the entry at 30
characters for entries with more than 30 characters in them (which, I freely
admit, is more than likely what the OP wants for this case) whereas the
formula I posted preserves all of the character typed in (just in case the
OP wants to be able to do that).

Rick

  #13   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 1,231
Default Custom Fields with spaces

"Rick Rothstein (MVP - VB)" wrote...
=REPLACE(REPT(" ",30),1,LEN(A1),A1)


Wouldn't

=LEFT(A1&REPT(" ",30),30)

....
Well, that is the same formula that Dave posted... I posted my formula in
order to provide the OP with a choice in case the user enters more than 30
characters. Your (and Dave's) formula will truncate the entry at 30
characters for entries with more than 30 characters in them (which, I
freely admit, is more than likely what the OP wants for this case) whereas
the formula I posted preserves all of the character typed in (just in case
the OP wants to be able to do that).


Didn't see Dave's response. So how 'bout

=A1&REPT(" ",MAX(0,30-LEN(A1)))

?


  #14   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default Custom Fields with spaces

=REPLACE(REPT(" ",30),1,LEN(A1),A1)

Wouldn't

=LEFT(A1&REPT(" ",30),30)

...
Well, that is the same formula that Dave posted... I posted my formula in
order to provide the OP with a choice in case the user enters more than 30
characters. Your (and Dave's) formula will truncate the entry at 30
characters for entries with more than 30 characters in them (which, I
freely admit, is more than likely what the OP wants for this case) whereas
the formula I posted preserves all of the character typed in (just in case
the OP wants to be able to do that).


Didn't see Dave's response. So how 'bout

=A1&REPT(" ",MAX(0,30-LEN(A1)))


Okay, that is another way to do it. My guess is that if we keep trying,
there are probably a few other ways to accomplish this. Are you proposing
that your formula is the better one to use for some reason (perhaps, it's
more efficient or faster)?

Rick

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
Microsoft Query sometimes adds trailing spaces to fields No Name Excel Discussion (Misc queries) 1 June 4th 07 03:17 PM
File/custom Property fields KC Excel Discussion (Misc queries) 9 July 15th 06 12:08 PM
Add spaces for specific fields to paste in Corey Excel Discussion (Misc queries) 3 December 30th 05 10:22 PM
Custom Format alphanumberic value with spaces Bruce Excel Worksheet Functions 2 November 28th 05 12:04 PM
Pivot tables - custom fields Yof Excel Discussion (Misc queries) 1 April 19th 05 11:35 PM


All times are GMT +1. The time now is 05:41 PM.

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

About Us

"It's about Microsoft Excel"