Set the Length of the Cell

  • Thread starter Thread starter carl
  • Start date Start date
C

carl

I am looking for a formula that can take a value in a given cell and
depending on how many characters in the cell, add "spaces" so that the
totl length is 5 characters.

For example.

I have these value in Col A:

A
AA
AAP
AAPL
AAPL1

I would like a formula for Col B that woudl produce this result:

A____
AA___
AAP__
AAPL_
AAPL1

Where the "underscore" represent a "blank space".

Thank you in advance.
 
Try this:

=IF(LEN(A1)>5,LEFT(A1,5),A1&REPT(" ",5-LEN(A1)))

This will truncate the string to 5 characters if it is longer.

Hope this helps.

Pete
 
Back
Top