Solved

Text with trailing spaces

Posted on 2012-04-03
7
272 Views
Last Modified: 2012-04-20
I need formula to convert text in cell to 10 characters in length inside quotes.


value in A1 B1000 to "B1000     "
0
Comment
Question by:cebu1014
7 Comments
 
LVL 7

Accepted Solution

by:
ZShaver earned 250 total points
ID: 37803648
you can set B1 to:
=A1&REPT(" ",10-LEN(A1))

and B1 will have the padded value

however you cannot place the formula in A1 because that cell contains the data and this would create a circular reference
0
 
LVL 7

Expert Comment

by:ZShaver
ID: 37803686
why would you want to do this anyways, doesn't make a lot of sense, maybe if you give us an explanation of the problem we can come up with better solution.
0
 

Author Comment

by:cebu1014
ID: 37803704
The result will be copied to text file for importing into program.
Can I  get the display to show "B1000    " in excel?
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 41

Expert Comment

by:dlmille
ID: 37803713
Not for points:

In case cell A1 has trailing spaces in it, already, I would recommend a slight modification to ZShaver's tip:

[B1]=TRIM(A1)&REPT(" ",10-LEN(TRIM(A1)))

and copy down.  You can then copy B column and paste value to A column



Cheers,

Dave
0
 
LVL 7

Expert Comment

by:ZShaver
ID: 37803850
Can I  get the display to show "B1000    " in excel?
well, you can't see spaces, but if u underline the cell you can see it is working
0
 
LVL 8

Expert Comment

by:wchh
ID: 37804480
If you have mutiple columns,
You may adjust the column width, for example 10.
Save as "*.prn" file.
The column will be displayed as 10 characters include spacing.
0
 
LVL 14

Assisted Solution

by:Otto_N
Otto_N earned 250 total points
ID: 37806103
I might be missing the point, but it seems that you want to include the double-quotes in the display?  Then just concatenate "CHAR(34)" before and after ZShaver or dlmille's suggestion, i.e
B1=CHAR(34) & A1&REPT(" ",10-LEN(A1)) & CHAR(34)
  or
B1=CHAR(34) & TRIM(A1)&REPT(" ",10-LEN(TRIM(A1))) & CHAR(34)

This will return the text string including quotes.  Just note that, if the input text string is longer than 10 characters, you will receive a "#VALUE"-error.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Creating an OSPF network that automatically (dynamically) reroutes network traffic over other connections to prevent network downtime.
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 Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now