PC Review


Reply
Thread Tools Rate Thread

Add leading spaces to text

 
 
Gary
Guest
Posts: n/a
 
      22nd Jun 2004
I need to add leading spaces to a text field. The field
needs to be 12 "characters" long with any "spaces" leading
the text. for example instead of "apple" I want to
format to " apple" and "orange" to " orange"


 
Reply With Quote
 
 
 
 
Juan Sanchez
Guest
Posts: n/a
 
      22nd Jun 2004
Gary

I'm not sure there is a non-VBA of doing this without
having to add another column... adding another column you
could use this:

=LEFT(" ",12-LEN(A1))&A1

Big gap is 12 spaces...

pls reply if you are interested in a VBA (macro) way to do
this...

Cheers
JS




>-----Original Message-----
>I need to add leading spaces to a text field. The field
>needs to be 12 "characters" long with any "spaces"

leading
>the text. for example instead of "apple" I want to
>format to " apple" and "orange" to " orange"
>
>
>.
>

 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      22nd Jun 2004
Why don't you align right?

This should do what you want

Sub addspaces()
For Each c In Selection
c.Value = Space(12 - Len(c)) & c
Next c
End Sub

--
Don Guillett
SalesAid Software
(E-Mail Removed)
"Gary" <(E-Mail Removed)> wrote in message
news:203a001c45899$46a75af0$(E-Mail Removed)...
> I need to add leading spaces to a text field. The field
> needs to be 12 "characters" long with any "spaces" leading
> the text. for example instead of "apple" I want to
> format to " apple" and "orange" to " orange"
>
>



 
Reply With Quote
 
RagDyer
Guest
Posts: n/a
 
      23rd Jun 2004
Try this:

=REPT(" ",12-LEN(A1))&A1
--

HTH,

RD
==============================================
Please keep all correspondence within the Group, so all may benefit!
==============================================


"Gary" <(E-Mail Removed)> wrote in message
news:203a001c45899$46a75af0$(E-Mail Removed)...
I need to add leading spaces to a text field. The field
needs to be 12 "characters" long with any "spaces" leading
the text. for example instead of "apple" I want to
format to " apple" and "orange" to " orange"


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace leading zeros with leading spaces ? Gary Microsoft Excel Programming 4 7th Jan 2010 12:39 PM
What excel snyntax and or function will add leading spaces Sharon Microsoft Excel Worksheet Functions 3 17th Apr 2008 02:46 AM
how do I remove leading spaces and leave the remianing spaces w =?Utf-8?B?RGViaQ==?= Microsoft Excel Worksheet Functions 6 28th Feb 2007 04:29 PM
How do I add leading spaces to a value? =?Utf-8?B?Q2hyaXMgIEJyb3du?= Microsoft Excel Worksheet Functions 5 3rd Mar 2006 06:32 PM
add ability to strip off leading/trailing spaces from email regularExpressionValidator? Les Caudle Microsoft ASP .NET 2 10th Mar 2004 06:58 PM


Features
 

Advertising
 

Newsgroups
 


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