Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Add a leading zero to number cells in Excel

Posted on 2013-01-31
2
Medium Priority
?
482 Views
Last Modified: 2013-02-01
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
Comment
Question by:paulmac110
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 93

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 1000 total points
ID: 38839225
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
 
LVL 70

Accepted Solution

by:
KCTS earned 1000 total points
ID: 38839617
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question