ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   What excel snyntax and or function will add leading spaces (https://www.excelbanter.com/excel-worksheet-functions/184040-what-excel-snyntax-function-will-add-leading-spaces.html)

Sharon

What excel snyntax and or function will add leading spaces
 
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?

Teethless mama

What excel snyntax and or function will add leading spaces
 
=A1&REPT(" ",7-LEN(A1))

"Sharon" wrote:

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?


Bernard Liengme[_2_]

What excel snyntax and or function will add leading spaces
 
=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

--
www.stfx.ca/people/bliengme


"Sharon" wrote:

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?


Dave Peterson

What excel snyntax and or function will add leading spaces
 
A couple mo

=right(rept(" ",7)&a1,7)

=left(a1&rept(" ",7),7)



Sharon wrote:

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?


--

Dave Peterson


All times are GMT +1. The time now is 12:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com