What excel snyntax and or function will add leading spaces

S

Sharon

I have a requirement to have meet a specified field length. For example if
name field length is 7 and the name entered is SAM; what functions
(operations, marcos, vb scripts) are available in excel that can
automatically add either leading or trailing spaces to make the length equal
to 7?
 
B

Bernard Liengme

=LEFT(" ",7-LEN(A1))&A1
there are 7 spaces between opening and closing "
or
=A1&LEFT(" ",7-LEN(A1))

But you now have SAM in cole column and SAM____ in another
You could use copy followed by Paste Special with Values specified to make
the first column unneeded but this would be after all data was entered.

If you want the change to happen on the fly, please post Q to the
Programming group

best wishes
 

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