Computing.Net > Forums > Office Software > Formula with spaces

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Formula with spaces

Reply to Message Icon

Name: bijan
Date: October 7, 2009 at 15:43:48 Pacific
OS: Windows Vista
Product: Microsoft Excel 2007
Subcategory: Microsoft Office
Tags: excel, spaces, formula
Comment:

Hi, I'm wondering if there is a formula that will get a condition if a cell has less that 4 digits, to input extra spaces to add to 4 digits. E.g:
one column has:
4564
7898
4569
345
4567
87
3467

What I need is that the formula inputs extra spaces so it will add make it a four digit "number" like this

4564
7898
4569
*345
4567
**87
3467
(where the asterisks are, I need spaces. This post won't take spaces before numbers, that's the reason for the asterisks)

I need this to line up the numbers to the right after I concatenate those numbers and paste them in a text file for so an old program can import it.

Thanks.

George



Sponsored Link
Ads by Google

Response Number 1
Name: Mike (by mmcconaghy)
Date: October 7, 2009 at 19:06:10 Pacific
Reply:

Simply right justify doesn't work?
Would adding Zero's work?

MIKE

http://www.skeptic.com/


0

Response Number 2
Name: Mike (by mmcconaghy)
Date: October 7, 2009 at 19:27:39 Pacific
Reply:

Here's something that should work:
This assumes that there is at least one number in the cell.

=IF(LEN(A1)=1,CHAR(32)&CHAR(32)&CHAR(32)&A1,IF(LEN(A1)=2,CHAR(32)&CHAR(32)&A1,IF(LEN(A1)=3,CHAR(32)&A1,A1)))

MIKE

http://www.skeptic.com/


1

Response Number 3
Name: jon_k
Date: October 8, 2009 at 01:20:37 Pacific
Reply:

or, to save work on your fingers:

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


1

Response Number 4
Name: Bryco
Date: October 8, 2009 at 04:47:43 Pacific
Reply:

Select the column, Go to Format, Cells, Custom and use ????

Best regards,
Bryan


0

Response Number 5
Name: Humar
Date: October 8, 2009 at 04:54:51 Pacific
Reply:

Hi Bryco,

Changing the formatting of the cell doesn't change the data.

If you have 123 in cell A1 and test its length =len(A1) you get 3.
Format the cell with ???? or 0000 and its appearance will change but len(A1) still returns 3.

Regards


0

Related Posts

See More



Response Number 6
Name: bijan
Date: October 8, 2009 at 08:18:12 Pacific
Reply:

Thanks guys, works like a charm.


0

Response Number 7
Name: DerbyDad03
Date: October 8, 2009 at 08:33:05 Pacific
Reply:

What works like a chram?

You were offered various suggestions and it might help someone in the future if you tell us which solution worked for you.


0

Response Number 8
Name: bijan
Date: October 8, 2009 at 09:25:44 Pacific
Reply:

Yes, you are right. Both solutions from Mike and Jon work the same way. This is practical when you have and old system in unix that needs a text file with the exact spaces to process. Thanks again.


0

Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Formula with spaces

dragging formula with a sheet name www.computing.net/answers/office/dragging-formula-with-a-sheet-name/8881.html

Need help with Excel formula www.computing.net/answers/office/need-help-with-excel-formula-/8135.html

How to Move Directory With Spaces In Between? www.computing.net/answers/office/how-to-move-directory-with-spaces-in-between/9136.html