Add leading spaces to text

  • Thread starter Thread starter Gary
  • Start date Start date
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"
 
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
 
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
 
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"
 
Back
Top