Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Text function for trailing spaces

Posted on 2013-06-11
5
Medium Priority
?
287 Views
Last Modified: 2013-06-12
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
Comment
Question by:cebu1014
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 13

Assisted Solution

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

Considering the cell is A2
0
 
LVL 93

Accepted Solution

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

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

Expert Comment

by:Shanan212
ID: 39238558
I see what you did there! :)
0
 
LVL 93

Expert Comment

by:Patrick Matthews
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

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question