Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

Add a leading zero to number cells in Excel

Hi - I want to automatically add just one leading zero to number cells in Excel through formatting.

E.g. 6 should be 06, 97 should be 097 and 125 should be 0125.

Thanks.
0
paulmac110
Asked:
paulmac110
2 Solutions
 
Patrick MatthewsCommented:
The easiest way would be to just use a formula to add the leading zero and return it as text:

="0"&A2

If you can guarantee that the biggest number in that column will be less than 1000, you could use this custom number format:

[<10]00;[<100]000;0000

To get fancier than that, you are going to need VBA, probably an event sub on the Change or Calculate events to apply number formatting on a cell-by-cell basis, which I do not recommend.
0
 
KCTSCommented:
Why not just use formatting

Select the cells, then Use Format Cells->Custom and enter the custom format "0000"
this forces all cells to have four digits - leading zeros will be added as appropriate
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now