OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

TEXT function: format code for padding with zeros?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
taraAthan
Newbie
Newbie


Joined: 10 Nov 2007
Posts: 4

PostPosted: Sat Nov 10, 2007 9:26 am    Post subject: TEXT function: format code for padding with zeros? Reply with quote

I frequently need to convert from numbers (1,2, ...13, ... 123) to text ('001, '002, ...'013, ... '123). Is there a simple way to use the TEXT function (or anything else) to pad with zeros to give a string of fixed length?
Back to top
View user's profile Send private message
h1h
OOo Enthusiast
OOo Enthusiast


Joined: 18 Jun 2006
Posts: 152
Location: Switzerland

PostPosted: Sat Nov 10, 2007 10:17 am    Post subject: Reply with quote

=TEXT(B15;"000")

will display the number in B15 as Text with leading zeros.
So you might concatenate e.g. =TEXT(B15;"000") & TEXT(C15;"000") & TEXT(D15;"000")
etc.
_________________
OOo 2.3 on Linux
Back to top
View user's profile Send private message
David
Super User
Super User


Joined: 24 Oct 2003
Posts: 5668
Location: Canada

PostPosted: Sat Nov 10, 2007 11:51 am    Post subject: Reply with quote

Numbers in column A. In a distant cell [K1 ?], have a string of zeros, prefixed by an apostrophe to force text format. Suppose you wanted to have 5 digit figures:

In B1 put this....

=LEFT($K$1;5-LEN(A1))&A1

Adjust according to the number of digits you need.

Copy down column B.

David.
Back to top
View user's profile Send private message
taraAthan
Newbie
Newbie


Joined: 10 Nov 2007
Posts: 4

PostPosted: Sat Nov 10, 2007 1:33 pm    Post subject: Documentation of Format Codes? Reply with quote

Those are both great! Thanks.
I would especially like more information on the format code in
TEXT(B15;'000') - I can't find anything in the documentation about format codes.
Is this written up somewhere?
Back to top
View user's profile Send private message
acknak
Moderator
Moderator


Joined: 13 Aug 2004
Posts: 4295
Location: ~ 40°N,75°W

PostPosted: Sat Nov 10, 2007 2:44 pm    Post subject: Reply with quote

Help > OO.org Help > Index > "format codes;user-defined number formats"

At the bottom of that page, there's a link to "Custom format codes". or you can use the index under "format codes;numbers"
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group