put 0 in front of number

D

dlb1228

i have a field that has a number in it for example
100
115
116
12

i want these to always be 4 digits and put zeros in front of the number
how can i do this
 
B

Bob Phillips

Format it as 0000 (Format>Cells>Custom)

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)
 
T

T Kirtley

You can use a formula like =TEXT(A4,"0000") to force padded zeros to show, or
you can make a custom number format like 0000 to make up to 4 leading zeros
show, (but the actual data will not be changed)

Hope that helps,

TK
 
N

Nick Hodge

You can 'display' it as four digits by selecting the data, going to
Format>Cells...>Custom and type 0000 in the text box

I stress display...the underlying data is still a number without leading
zeroes

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
[email protected]
 
M

Marcelo

Hi

=rept("0",4-len(a2))&a2


assuming that the 100 are in A2, please, have notice that the numbers will
be a text.

Hope this helps
Regards from Brazil - going to the 6th
Marcelo


"dlb1228" escreveu:
 
D

Dave Peterson

You can preformat the cells as Text first and type all 4 digits.

You can prefix the entry with an apostrophe: '0012

Or you can give the column a custom format of: 0000
(Format|Cells|number tab|custom category and type 0000 in that box)

The value won't change, but you'll see leading zeros in the cell (not in the
formula bar, though).
 
Top