Solved

# Text function for trailing spaces

Posted on 2013-06-11
239 Views
If I have a  cell that contains something less than 12 characters , how can I get spaces added on end where total length is 12 characters in field?
0
Question by:cebu1014
• 2
• 2

LVL 13

Assisted Solution

Shanan212 earned 250 total points
ID: 39238289
=IF(LEN(A2)<12,A2&REPT(" ",12-LEN(A2)),A2)

Considering the cell is A2
0

LVL 92

Accepted Solution

Patrick Matthews earned 250 total points
ID: 39238535
No need for the IF, really :)

=LEFT(A2&REPT(" ",12),12)
0

LVL 13

Expert Comment

ID: 39238558
I see what you did there! :)
0

LVL 92

Expert Comment

ID: 39238700
cebu1014,

Please note that my formula might mishandle entries that are already >12 characters long.  For example, if the original entry is 17 characters long, my formula will truncate at the 12th character, while Shanan212's formula will return all 17 characters (and not add any trailing spaces).

Only you know whether or not there would ever be any initial data with >12 characters, and what should happen in that event.

:)

Patrick
0

Author Comment

ID: 39242000
It will be 12 characters max. Never longer.
0

## Featured Post

### Suggested Solutions

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.