ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How do I add leading spaces to a value? (https://www.excelbanter.com/excel-worksheet-functions/75152-how-do-i-add-leading-spaces-value.html)

Chris Brown

How do I add leading spaces to a value?
 
I have a list of values that vary in length, but I need to convert all of
them to 10 characters with spaces, not 0's as prefixes.

I have been able to use the text command to add 0's, but unable to add spaces.

Thanks in advance for any help!

-Chris

Niek Otten

How do I add leading spaces to a value?
 
Hi Chris,

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

--
Kind regards,

Niek Otten

"Chris Brown" wrote in message
...
I have a list of values that vary in length, but I need to convert all of
them to 10 characters with spaces, not 0's as prefixes.

I have been able to use the text command to add 0's, but unable to add
spaces.

Thanks in advance for any help!

-Chris




Ron Coderre

How do I add leading spaces to a value?
 
Try something like this:

For a value in A1
B1: =RIGHT(TEXT(A1," 0"),10)

Note: That format includes 10 spaces before the 0.

Does that help?

***********
Regards,
Ron

XL2002, WinXP-Pro


"Chris Brown" wrote:

I have a list of values that vary in length, but I need to convert all of
them to 10 characters with spaces, not 0's as prefixes.

I have been able to use the text command to add 0's, but unable to add spaces.

Thanks in advance for any help!

-Chris



How do I add leading spaces to a value?
 
Hi

Try something like this:
=REPT(" ",10-LEN(A2))&A2

Once done, you'll have to Copy the range and then Edit/Paste Special/Values
to fix the values.

Hope this helps.
Andy.

"Chris Brown" wrote in message
...
I have a list of values that vary in length, but I need to convert all of
them to 10 characters with spaces, not 0's as prefixes.

I have been able to use the text command to add 0's, but unable to add
spaces.

Thanks in advance for any help!

-Chris





All times are GMT +1. The time now is 08:27 PM.

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