I have a column comprised exclusively of numbers. Whenever I add 050, the sheet automatically changes it to 50. I have tried prepending a space, but it makes no difference.
What can I do to avoid this?
If there's a difference between 50
and 050
, what you have are strings
(i.e. text).
Changing the cell format to Plain Text
via Format
>Numbers
>Plain Text
will keep leading zeros.
Since @jam 's answer there might be some improvement in Spreadsheet's features.
If you'd like to preserve and use the numbers as figures (e.g., automatic fill) you might apply the settings from the
Format > Number > More Formats > Custom number format...
menu, and set the pattern to 000
, where the number of zeros represent the number of digits to which the completion will be made with the leading zeros.
A quicker way of formatting a cell as text, is to add a preceding apostrophe to your number. In a cell, type
'050
and it will be interpreted as the string 050
.
Another option is to write it as a formula:
="050"
050
, not any interpretation of it.
Commented
May 18, 2016 at 7:16
I needed to have a leading zero on the current month of the year for creating a custom date code I use on my invoices. This is what I did:
=IF(LEN(MONTH(TODAY()))=1;CONCATENATE(0,MONTH(TODAY()));MONTH(TODAY()))
If you came here looking for a way to add a leading zero to a time cell, select "Custom number format" from the dropdown and set this value:
hh":"mm":"ss
You can format the contents of the cell as Plain Text
.
An external link failed. Answer as suggested in a comment by @RickyClarkson: