Solved

Add a leading zero to number cells in Excel

Posted on 2013-01-31
2
437 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
2 Comments
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 250 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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now