Add leading spaces to text

G

Gary

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"
 
J

Juan Sanchez

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
 
D

Don Guillett

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
 
R

RagDyer

Try this:

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

HTH,

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


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"
 

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