Leading Zeros

jcm996

New Member
Joined
Sep 6, 2003
Messages
23
Is there anyway to make excel leave leading zeros? I have a client who has account number like 0147364 and when trying to manipulate data in excel it removes the leading zero leaving 147364. Can this be stopped?

Thanks
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Another option is to format the cell with a custom number format:

i.e. 00000000 if there are 8 digits in the account number,

though I am sure there are added benefits to formatting the cell as text that Aladin would be better able to enlighten us about.
 
Upvote 0
I have always preferred BuddieB's approach...but I do wonder why Aladin said to format as text.
 
Upvote 0
I deal with ISBN numbers a lot and I have the same problem. I use the following code alot to fix this problem.
Code:
If Mid(C.Value, 1, 8) Like "########" Then
        C.NumberFormat = "@"
    Select Case Len(C.Value)
        Case 8
                C.Value = "00" & C.Value
        Case 9
                C.Value = "0" & C.Value
    End Select
End If
ISBN numbers are always 10 digits. This code formats the cell C as text and "fixs" the number by adding the missing zeros. This will not work if you are not using VB or if the number of digits is not fixed. Otherwise, you just have to be very careful to set the format to text before you put the data in.

If anyone knows a way to turn this function off in excel I would love to know.
 
Upvote 0
BuddieB said:
Another option is to format the cell with a custom number format:

i.e. 00000000 if there are 8 digits in the account number,

though I am sure there are added benefits to formatting the cell as text that Aladin would be better able to enlighten us about.

Not a great mystery. When you do e.g., a Vlookup, you might run into trouble, in particular when you download the related data from other systems.
 
Upvote 0
Thanks for the help and the warning on vlookup, but that really won't be used anyway. Basically we use excel to allow our customers to recieve large number of account from their clients, then we just put special column headers on, save as tab delimited and our software will load all the data for them. Saving hours of data entry time.

Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top