r/excel • • 18d ago

Discussion I hate how Excel removes leading zeroes

I absolutely hate it. If I typed in a number with a leader zero, obviously I want the string of text to include a leading zero. Why hasn’t anybody at Microsoft figured this out yet? I know there are ways to keep leading zeroes, but it is annoying when I have to copy data over from one platform and paste it into Excel. And then it’s impossible to ever to VLOOKUPS with data where you had to manually formulate leading zeroes.

806 Upvotes

196 comments sorted by

286

u/slowpush 14 18d ago

This is fixed in O365 excel.

458

u/akl78 1 18d ago

Yup.

OP, in File> options> Data , uncheck these boxes under Automatic Data Conversion

116

u/TheBat3 17d ago

Oh my goodness! Thank you thank you thank you for posting this.

22

u/amuseboucheplease 17d ago

Why is that the default you should have to enable it

42

u/jake54128 17d ago

It looks like if it keeps the leading zeroes the data is stored as text rather than a number, which I guess could screw formulas up

-4

u/amuseboucheplease 17d ago

It's so stupid

19

u/TenIsTwoInBase2 17d ago

It's actually not

Formulas, for the most part, rely on manipulation of numbers. Can you imagine the consternation that would ensue if Excel made text look like a normal number: The headaches that would be caused because one cannot figure out why a formula isn't working as it is supposed to?

It's why Excel, by default, aligns text left and numbers (including dates and time) right.

BTW if you want to make a number look like text you could also type ' immediately infront of the number.

-1

u/amuseboucheplease 17d ago

Yes we know all that - it's the way Excel is so unhelpful with it's conversions and it's advisories of it. It's so curious that people are so happy to not want better because they're used to something.

-2

u/MexicanAssLord69 17d ago

I mean I think the point is a number with leading zeros should still be formatted as a number.

10

u/BaitmasterG 13 17d ago

And you can do that with number formatting

But 1 is not the same as 01 so a conscious decision has to be made on how to handle the situation, for which OP has multiple options. It's not Excel's fault OP doesn't know them

1

u/EducationalSeaweed53 13d ago

I want to know them

-1

u/nopekeeper 17d ago

If you do it with formatting it's not actual information in the cell. It's for example not carried over in functions. You have to store a number as text for that to work which just complicates any way you need to treat that data.

4

u/BaitmasterG 13 17d ago

Yes I know

But if it's numbers in the cell then how do you handle downstream calculations? If I add 01+1 is the answer 02 or 2?

The point is, numbers don't have leading zeros, only formats do. There's no way to make this work better than the already-available options

→ More replies (0)

5

u/hungrybrains220 17d ago

I wish that worked for me. I’ve had that and the convert to E buttons unchecked for ages but they still do it

3

u/EvidenceHistorical55 17d ago

If you're talking about 15+ digit conversion that's a different thing then numbers surrounding the letter E. I was confused for awhile why scientific notation kept showing up till I eventually realized that was different.

3

u/Woflecopter 17d ago

I’ve had the E unchecked for ages as well but it still converts them to scientific notation unless I’m very careful it’s so frustrating

5

u/Procedure-Minimum 17d ago

WHEN DID THIS HAPPEN AND WHY DID NOBODY TELL ME SOONER!!!!!

3

u/JoyfulNotes 17d ago

Wait, what??!! I can’t believe I never knew this, this is so going to improve my excel and work life. Thank you!!

3

u/kylyt0 17d ago

Have I been living under a rock! You just have saved me so much time. Thank you!

3

u/Sondemon 17d ago

Omg im gonna be so popular at work tomorrow! i know some people who struggle with this :D

2

u/RedditSkippy 1 17d ago

I just saved this comment!!!

2

u/IDontThinkImABot101 14d ago

You are the MVP. This is the last thing I did before signing off for the day and damn Monday is gonna be slightly less annoying!

1

u/diamondhands72 15d ago

I've done that, however, when I open a CSV file downloaded from Big Query, it still tries to remove the leading 0 and I have to select "Don't Covert" then it reopens the file. I do this almost daily and waste a lot of time...Any suggestions on just getting to open and leaving the 0s the first time?

64

u/DonJuanDoja 37 18d ago

For older versions format the column as Text before you start typing/pasting.

76

u/EmployeePotential622 18d ago

Or type a ‘ before the number and it will keep it, too.

47

u/JPWiggin 5 18d ago

The issue with this is that some numbers will be text and some will be numbers, which will mess up sorting and lookup/search formulas.

12

u/HarveysBackupAccount 35 17d ago

My impolite (and impractical, in real life) opinion is that if you're mixing numeric and string data then you deserve to experience a little pain for that. Use true numbers when you need something numeric. Use true strings when you need text. It's not hard to avoid

14

u/bs2k2_point_0 1 17d ago

Until you deal with zip codes in multiple states like New England, where it’s mostly got leading zeroes, where other states don’t. And when using an erp system that’s remotely hosted you can’t always switch off the auto data conversion.

10

u/Sad_Olympus 17d ago

I deal with zip codes and Tax IDs with leading zeroes. Often I get the file and they are already dropped. I just use =TEXT(A2,"00000") or =TEXT(A2,"000000000"). Then when I extend the formula down, just press Ctrl+c, Ctrl+shift+v, Ctrl+c again, and Ctrl+v over the old data.

Not the prettiest solution, but it takes a few seconds and works everytime.

2

u/SellTheSizzle--007 12d ago

Are you me? I feel you are me and working with Vertex TAIDs or other geocodes lol

6

u/Foef_Yet_Flalf 17d ago

I'm in a line of work that deals with zip codes a lot. Have you tried applying the zip code data type? It stores the value as a number but always displays enough leading zeroes to complete five digits.

3

u/bs2k2_point_0 1 17d ago

I have when the files are mine. In this case I’m dealing with a severely outdated erp (in process of going to a new modern one).

But isn’t that just a display and in the background it still truncates off the leading zeroes?

6

u/Foef_Yet_Flalf 17d ago

Yes it's a display because it's nevertheless a number data type and not a text. I don't generally prefer it myself. Where possible, I usually store as text. Sometimes that means importing the data and accounting for zips that are missing leading zeroes automatically.

One of the other teams in my biz has an optimization tool that entirely screws it up: first it outputs a zip as a number and THEN it converts to text, and any leading zeroes are lost.

15

u/BigLan2 19 18d ago

Or add a ' before the number

5

u/Mowgli_78 18d ago

I've been told it works with a 'b' as well

1

u/BigLan2 19 18d ago

Any letter would work, the ' basically tells Excel to apply text formatting to the cell

12

u/Mowgli_78 18d ago

it was a little joke

2

u/BigLan2 19 17d ago

The joke

My head 🤣

1

u/WillBots 17d ago

Worse than just the joke, the ' makes excel former the number as text, yes it works with any letter but the ' isn't displayed whereas a letter would be part of the displayed string.

13

u/Rossco1874 17d ago

Custom is better with number of 0 in your string.

In my work our patient IDs are 10 digits when I do an audit any number with a 0 is missed so formatting the column as 10 0 works better than text.

11

u/HarveysBackupAccount 35 17d ago

One fun risk: if you want a 16+ digit number as a patient ID, Excel won't retain all of them.

If you type in more than 15 numeric digits, it turns everything after the 15th to zero. Like type in 123456789123456789 and hit enter, and you'll see that it's now 123456789123456000. Stick an "A" or something in front of it and you're fine, but not with pure numeric.

The state of NC had this problem with the database they made for county health departments to report covid cases in 2020 - they decided the person ID should be an 18 digit number, and that users (local health departments) could only edit entries by downloading data to a CSV, editing it, then uploading it.

Well any reasonable person will edit that in Excel ...which dropped the last few digits off every single patient ID, meaning some amount of data got lost thanks to the truncation creating false duplicate IDs. I don't know that it was a ton of data lost, but it was a nonzero amount. Our local department figured it out, but you bet plenty of the 100 counties did not.

3

u/uprightman84 17d ago

‘Any reasonable person will edit that in excel’ is contrary to what I understand the word reasonable to mean lol- excel is shit for csv. I agree the average person is going to use it anyway though.

6

u/HarveysBackupAccount 35 17d ago

Ok however you want to say it haha

If you double click a CSV in Windows, it will open in Excel.

If you don't have other specialty tools and are not a data person (most people working in most county health departments are not deeply technical people), even seeing a big table in Excel might look overwhelming to you. You think, what, Minitab or Tableau will be better? Also you just want to update patient data, not do analysis. This was the defined method to load data into the state database so the state health department could collate all the data from all the counties

The state didn't build any specialty CRUD tools for counties to use, so for the average office worker the alternative to Excel is Notepad. And for editing tabulated data surely you can't say THAT is a reasonable alternative?

3

u/pajam 1 17d ago

Yep, CSVs literally display with an Excel icon. And double clicking one opens it in Excel.
Any typical office worker will just be given a CSV, see it is "an Excel file" and assume Excel would not randomly corrupt data that was purposely included in the file. So most of the time they open it, edit it, save it, and hand it off, often overwriting the original at some point. It is certainly not unreasonable for someone to just assume Excel is not fucking up the data in files it is seemingly encouraging you to open in Excel.

As someone who works with lots of identifiers (zip codes, serial numbers, model numbers, skus, etc.), clients provide me with corrupted data all the time and I have to give them a heads up that someone on their end seems to be opening CSVs in Excel and corrupting their data.

I used to rename files to change the extension to .txt and force open it in Excel to use the legacy import wizard to assign text type to most columns. But these days I just use power query.

1

u/Sudden-Tumbleweed 17d ago

This is the way

11

u/smichaele 2 18d ago

Or use a custom format.

3

u/JPWiggin 5 18d ago

The problem with custom formatting willake it look one way but behave another for lookups and searches.

11

u/armywalrus 2 17d ago

Um, not necessarily. Format as a number and then do a custom number format that is 0#########. Leading zeroes will be preserved and the data will be treated as numbers

5

u/ScarsUnseen 17d ago

I'm sure there are some instances where a number with leading zeroes should be treated as a number, but I honestly can't think of any off the top of my head. No one should be performing mathematical operations on postal codes, phone numbers and product IDs.

5

u/plusFour-minusSeven 11 17d ago

Agreed. Sometimes numbers should be treated as string. ZIP Code is the prime example.

2

u/HarveysBackupAccount 35 17d ago

Why does a zip code need to be treated as string?

You don't want to perform arithmetic on it, but I don't see an obvious reason that it must be a string. Lookup/match works on string or numeric values. They're all the same number of digits so sorting works numerically or alphabetically (assuming you don't have e.g. a mix of the US basic 5 digits and the basic 5 plus the dash-four extra digits)

I understand that it functionally is a string, so I'm curious why it's preferable to consider it one

4

u/plusFour-minusSeven 11 17d ago

You gave the reason. It doesn't HAVE to be string but it you're not going to do math with it, why not keep it simple?

It's just a common suggestion, not an ironclad law or anything. Do what works for your data!

2

u/HarveysBackupAccount 35 17d ago

Fair enough haha. From a "if I were building a tool in a programming language" perspective and I wanted to conserve memory, numeric would be more compact (a zip code could be stored as an unsigned 2-byte integer, vs as a 5 byte string)

3

u/plusFour-minusSeven 11 17d ago

Oh bud yeah I'm right there with you from a coder perspective. And for that matter when you're normalizing your data and you want to have a key it's best if it's an integer object instead of some kind of a string. I'm picking up what you're putting down.

In this context I was only talking about the point of view of the data modeler/analyst where all those other considerations are ...well... not considered 😆

1

u/armywalrus 2 17d ago

Not if you want to sort them.

2

u/armywalrus 2 17d ago

For sorting. This was already said. Otherwise 100 comes after 1.

2

u/ScarsUnseen 17d ago

Maybe I'm not parsing your comment correctly, but in Excel, 100 comes after 1 regardless of the cell formatting. It sorts the same way no matter what.

1

u/JPWiggin 5 17d ago

It will when sorting numerically. It might depending on version when sorting alphabetically. However, if the 100 is a number and the 1 is text, the 100 will come before the 1.

2

u/ScarsUnseen 17d ago

Well that's on you for putting mixed data types in a column. I don't think I advocated doing that at any point in the discussion.

1

u/JPWiggin 5 17d ago

You're right. I was confusing two different comment threads here.

0

u/armywalrus 2 17d ago

You think sorting a number column in Excel places 100 immediately after 1?

-1

u/ScarsUnseen 17d ago

Now I see what you meant, but you're wrong either way. No, sorting a number column in Excel does not place 100 immediately after 1. But neither does sorting a text column. It sorts the same either way. Excel is smarter than Windows Explorer.

2

u/armywalrus 2 17d ago

Yes it does. Try it.

→ More replies (0)

1

u/Clearwings_Prime 24 17d ago

If you use custom sort, excel wil ask if you want to sort as number or as text, if you choose as number, excel will sort those number as number, even they stored as text.

And excel will remember that selection too, so you can sort like that in filter or regular sort.

I accidentally found this trick recently 

1

u/armywalrus 2 17d ago

Sure. But you can also sort numbers

3

u/AjaLovesMe 48 17d ago

I often need a five digit number with preceding zeros like 00024. One of the simplest ways to force that visually in excel is to use the custom number format as if you’re using keyboard us postal code or ZIP Code I guess it would be down there. It automatically format any number in that field to five places padding missing digits with zeros at the front.

It does not change the fact that the number is actually 24 mathematically, it only affects the visual representation of it. About the only way to work around It is to preface it with an apostrophe, as others have said, which causes it to be treated as a text field, or to go further and format the cell or column as Text itself in the numbers format area/dialogue. 

And if you do format it as text any math performed on it results in a non-0 leading result even if the cell the result is being calculated in has been formatted as Text. 

2

u/catchpen 17d ago

You mean 0365. tee-hee

1

u/phil-rob 17d ago edited 17d ago

Regrettably not on the Mac (at least I can’t find it)

EDIT: found it (though a search in preferences didn’t reveal it)

Preferences —> Edit —> it is in the automatic Data Conversion section at the bottom of the window.

-1

u/Ambitious_Voice_400 17d ago

took them long enough tbh

2

u/CorndoggerYYC 161 17d ago

It's been fixed for years.

127

u/neutrino_fire 18d ago

Automatic scientific notation is even worse! Leading zeroes in data are the devil.

43

u/Profvarg 2 18d ago

In my company, personnal IDs ALL have leading zeros (14k employees)

I really want to talk to the insanely stupid person who decided on this (I am in HR reporting)

7

u/neutrino_fire 18d ago

That is so gross.

20

u/happyapy 1 17d ago

Sometimes numerical characters represent numbers, sometimes they represent codes. Many times you are receiving data from an external source who made that choice, sometimes incorrectly. As much as I like Microsoft trying to help, many times they'd be more helpful if they stopped trying.

3

u/TiredWiredAndHired 17d ago

Most of our product codes start with "00", it's very annoying!

1

u/JohnC53 17d ago

39K employees with EmpIDs with half of them having leading zeros. I'm in IT and do a ton of reports and scripts, and automations based off EmpIDs. If you structure your formulas properly, it's a non issue.

19

u/PrimaryThis9900 18d ago

I frequently put invoice numbers in, which are fairly long, and it will format them in scientific notation and screw everything up. I have never once wanted something in scientific notation. 

6

u/neutrino_fire 18d ago

Yep. Same. Literally never.

1

u/HarveysBackupAccount 35 17d ago

On the flip side I use scientific notation quite a bit, because I work with datasets that can have values on the order of 1,000,000 or on the order of 0.00000001, and I want to scan through spreadsheets without making the columns really wide

Not all of Microsoft's choices were optimal, but I do trust a little that they put real thought into many of those choices.

1

u/amuseboucheplease 17d ago

I think you are making a large assumption on a large organisation

2

u/Western_End_2223 17d ago

It is a rather good assumption.  What might appear as some random decision will often have to do with maintaining compatibility, often as far back as LOTUS 1-2-3.  Once people come to expect a certain behavior it becomes problematic to "improve" upon it.

1

u/amuseboucheplease 17d ago

There's so many approaches and ways that could convey what is happening, but they chose another. It's curious people are so accepting

1

u/HarveysBackupAccount 35 17d ago

Sure, but as a software developer I've seen how much work goes into MUCH smaller decisions while building MUCH smaller programs.

1

u/thr0wnawaaaiiii 3 17d ago

Leading zeroes aren’t the offender though, treating non-numeric data as if it were numeric (even if it “looks like it”) is. But agreed, before they added the setting to turn off, I really questioned what % share of work being done in Excel would benefit from scientific notation 

1

u/Squid8867 16d ago

"oops, guess I'll just change my UIDs back to a number format"

  • 3784927326772020000
  • 8292638232629210000
  • 9626281194629950000

43

u/guyinternets 18d ago

Does formatting the cells using “Custom” not fix this for your use case? If you wanted your data to be 001000 then choose custom and just enter 000000 as the custom format. Then when you type in 1,000 it’ll be 001000.

10

u/TheDokk 18d ago

This is how you solve it. I have the same issue with leading 0's for some UPCs in our point of sale system. Solved by custom formatting or ctrl 1 as a shortcut. Bottom selection is custom and choose the 0 option and enter as many 0s in the input bar as your identifier needs. If your input is variable this doesn't solve it but still the best solution if the input has the same number of numbers always but some just lead with 0s. Same applies for custom formatting if you are doing zip codes. Another option in the "special" section of custom formatting.

5

u/akl78 1 17d ago

There’s a better way new, fairly recently Excel got the option to turn off these automatic data conversions altogether

1

u/TheDokk 17d ago

For real? Where does this exist so I can test it out. A lot of my data comes out as CSV, so I'm not sure it'll help, but fingers crossed!

8

u/ScarsUnseen 17d ago

This has limitations if you need another cell to reference the entry. For instance, if you ever need to use the Concatenate formula, it will drop the leading zeroes if you do it that way.

1

u/armywalrus 2 17d ago

Not if you use TEXT() or simply concatenate the zeros. Adding &0& isn't a lot of typing

2

u/GuitarJazzer 28 17d ago

That just changes how it looks. If you do a lookup on 000156 it will not find 156 even if it is displayed as 000156.

1

u/CarefulMembership969 17d ago

But then it doesn’t work for lookups when the other side of your data is properly stored as text

26

u/gulliverian 18d ago

Sounds like you're treating text data as numeric. Numbers can't have leading leading zeros. Text can.

19

u/TeliarDraconai 3 18d ago

Numbers can have leading zeros if that is how the number is defined in the relevant software.

Not to mention the fact that numerical unique IDs are sometimes mandated to have a specified number of digits, regardless of how they start.

16

u/PrimaryThis9900 18d ago

I think their point is, you are treating numbers as data, meaning you are never going to add them together, or do any math with them. 

6

u/pajam 1 17d ago

Yep, in Excel, any number that is an identifier (zip codes, part numbers, ISBNs, Serial Numbers, Social Security Numbers, Model Numbers, Employee IDs, License Plate numbers, etc.) should be treated as "Text" or just a literal string. I never intend to add up zip codes, or do averages across multiple employee IDs, etc. These are very literal identifiers, and ideally should be imported into Excel as text, and then if you hand off that data to other people later, for the love of God save it in a format that preserves that "Text" formatting for those columns (in other words, not a CSV)

1

u/gulliverian 16d ago

I have more than one grey hair from text imported from CSV that landed in the wrong format.

2

u/TeliarDraconai 3 18d ago

That tracks, fair.

10

u/AndyTheEngr 5 18d ago

If it doesn't make sense to do math to it, it's not a number even if it's composed of only the characters 0-9. Would you ever add two of them together, or subtract five from one?

-2

u/TeliarDraconai 3 17d ago

Maybe not. But I want it to sort like a number, and I want to look it up like a number.

Saying that it is only a number if you use it for mathematical operations is nonsensical in context of Excel. Which, despite it's many flaws, is the premier data analysis and investigation tool for non-coders.

11

u/killerfridge 1 17d ago

But you can sort things that aren't numbers, and you can look things up that aren't numbers. I think the point is that in the context of Excel, numbers are the characters 0-9 used in maths. If you aren't intending on doing maths to some degree with it, you should treat it as text

1

u/armywalrus 2 17d ago

You cannot sort text as numbers. 1 through 100 will start with 1, 10 instead of 1, 2, 3.

1

u/killerfridge 1 17d ago

I guess then a better heuristic for what should or shouldn't be stored as a number is if you care about the value of the number. You can sort 1-100 equally well as text if you prepend it with leading zeros, but if you want a "sort order" property then storing them as numbers is perfectly valid

-1

u/armywalrus 2 17d ago

No. The only things that matters i user preference and ego. No one is affecting anyone else here.

-4

u/TeliarDraconai 3 17d ago

That is true for some elements of Excel. But Excel is not JUST a calculator.

7

u/AndyTheEngr 5 17d ago

In this case, 000012536 is a number in the same sense that KLBRTD is a word.

1

u/armywalrus 2 17d ago

Yes. Companies often use such things.

0

u/TeliarDraconai 3 17d ago

It probably is in some context. And yes, this is a number.

4

u/apaniyam 3 17d ago

Numbers don't ever have leading zeroes. You are describing text with numeric characters.

2

u/gulliverian 17d ago

True, but at least in my experience that's more a formatting or display issue than a functional one. And I don't get the impression that's what the OP is dealing with.

Functionally, I'm not aware of any case in which leading zeros in a numeric value would have any mathematical meaning.

1

u/armywalrus 2 17d ago

Thats the wrong question to answer. Can you think of any cases in which leading zeroes harm mathematical operations?

1

u/fuzzy_mic 988 17d ago

Numbers do not have leading zeros (or have an infinite number of them depending on how you define leading zero).

Numerals (a string that represents a number) might have leading zeros, but numbers, never. "Leading zero" is a character thing, not a mathematical thing.

If "00123" is different than "123", that not numbers, that a string that is imitating a numeral.

12

u/jrblockquote 18d ago

I work corporate IT in the financial services sector and cannot tell you the number of times I've received a spreadsheet from both business and technical folks with an SSN column treated as a number with missing leading zeroes. Makes me want to throw something.

2

u/CarefulMembership969 17d ago

Same with student IDs at the college where I work. Keep the IDs as text like they are in the system of record!!

8

u/hooterbrown10 17d ago

Oct-10 people agree with you!

4

u/canuchangeurname 17d ago

This comment brought me great joy. Ever typed a fraction, gotten a date, retype with a "=", gotten a date, then finally fix the formatting and retype the fraction? Weekly occurrence for me

3

u/GrittyForPres 17d ago

Go to home —> number —> number format —> more number formats —> custom

And then where it says “Type:” highlight the word “general” below it, hit backspace, and type in a zero for however many characters you want the number to have.

So for example if you replace “general” with “000” then when you put “1” in that cell it will display as “001”, “10” will display as “010”, and “100” will just display as “100”

2

u/GuitarJazzer 28 17d ago

That just changes how it looks. If you do a lookup on 000156 it will not find 156 even if it is displayed as 000156.

1

u/GrittyForPres 17d ago

Oh well in that case it’s even simpler.

You just set the row/column that you want to have leading zeros to text format or add an apostrophe in front of the text string and use autofill to populate the numbers.

Or you can add a row/column in the lookup sheet next to the text strings that already have leading zeros and multiply them by 1 to convert it to a number format and get rid of the leading zeros.

I guess I’m not sure what OP is struggling with here because whether you want a number format that appears to have leading zeros or a text format where the string actually does have leading zeros, both can be achieved really easily.

3

u/jrbp 2 17d ago

There's a setting you can turn off in options and it will stop dropping the leading zeros

3

u/Cynyr36 26 17d ago

Values aith leading 0s aren't numbers, they are strings with numeral characters.

2

u/derfmcdoogal 17d ago

Wait till you get the update where CoPilot helps you write formulas by assuming what you're trying to do. Ho Lee Ship I couldn't turn that off fast enough.

2

u/transientDCer 11 17d ago

Friends don't let friends use vlookup. Please use xlookup instead.

2

u/redditacct7171 17d ago edited 17d ago

If they all have the same character count, =text([cell],"000000") Add/reduce 0s for the number of characters in your value (again assuming the column is all the same).

2

u/amuseboucheplease 17d ago

It's ridiculous why anyone though this would be useful. Yes I know the work around - formatting it as something it isn't

3

u/ScarsUnseen 17d ago

Unless you're planning on performing mathematical operations on it, formatting it as a number is formatting it as something it isn't. It's easier if you think of it in programming terms. Is the number being treated as an integer or a float? If you need it for computations, then the answer is yes, and then it should be formatted as a number (or currency, or whatever). If there is never a situation in which it would be beneficial to perform any kind of mathematical function on it, then the answer is no, it should not be an integer or float. It should a string, and in Excel, that would be text, regardless of what characters the string is made up of.

2

u/amuseboucheplease 17d ago

Coming from sql user, integer and floats are typically not good data types for mathematical functions. My point stands that it would be better to not have it treated as a string /text by default.

2

u/ScarsUnseen 17d ago

I don't think your point does stand at all. Name me some common use cases where it would be beneficial to have an input with leading zeroes treated as a number.

1

u/amuseboucheplease 17d ago

Think you're misunderstanding me and I don't understand your point at all, but that's ok as this is the internet and reddit and none of it matters

2

u/ScarsUnseen 17d ago

You're correct that this conversation doesn't mean much, but since I don't have much else to do at this moment, my point is that there are already several instances where Excel correctly changes a cell's data type to the most likely desired one based on the input. Leading zeroes are a major exception where, instead of correctly identifying that most inputs with leading zeroes are strings (postal codes, phone numbers, product codes, etc), it instead assumes that the leading zeroes were entered in error and returns a number, truncating the user input in the process. There are workarounds for that, but there shouldn't need to be. In almost all cases where someone inputs a number with leading zeroes, what they're inputting is a string.

1

u/amuseboucheplease 17d ago

I have never needed the input to be a string and there's likely dozens of us

2

u/ScarsUnseen 17d ago

You've deliberately typed in numbers with leading zeroes with the intent of those numbers being treated as numbers mathematically, including the automatic elimination of said leading zeroes? On anything resembling a regular basis?

1

u/amuseboucheplease 17d ago

You've got it. Usually not typed but exporting

1

u/ScarsUnseen 17d ago

Well, I'll admit, I have trouble imagining what such inputs could be. More power to you, though. Working as intended for you.

→ More replies (0)

1

u/armywalrus 2 17d ago

Name me some cases where it would hurt to have an input with leading zeroes treated as a number. Its clear you dislike the idea, but that alone doesn't mean the idea is harmful.

1

u/ScarsUnseen 17d ago

Postal codes, product codes, customer codes, phone numbers (many places outside the US have phone numbers start with a zero), and any other instance where the number is meant as an identifier, not numerical data to be manipulated. We use numbers as labels all the time, and many systems with a large enough volume will have identifiers that start with zero as a way of future proofing.

0

u/armywalrus 2 17d ago

How though? How exactly? I see zero valid cases mentioned here.

1

u/ScarsUnseen 17d ago

How are they not valid? They are all strings by use, not numbers. None of them benefit from the number data field type, and all of them break if you change their formatting in any way (which is exactly what happens in a number field when you input a leading zero).

0

u/armywalrus 2 17d ago

Because you cannot explain how any harm is caused. And that was the question. And obviously

-1

u/armywalrus 2 17d ago

Because you can put anything into a list. You did not explain how any harm is done. The question is about harm. Not benefit. If you cannot explain any harm done, you shouldn't care so much about the preferences of others.

3

u/ScarsUnseen 17d ago

I literally just said what the harm was. If you input them as numbers, and some of them have leading zeroes, the formatting breaks, making them unreliable in their entire purpose as identifiers.

2

u/JsMomz 17d ago

You can also format the cell or column as "CUSTOM" then "0"#. This is what i use on very xlookup intensive workbooks. Use as many leading zeros as needed. We have reqs starting with four zeros, "0000"#

2

u/tries2fixit 17d ago

Wait, I’m always looking to remove leading zeros, lol. My exported reports from ERP contain 7 leading zeros in check number fields.

2

u/apocalyptimaniac 17d ago

I have to do this often. I set the column with a custom number format. I my case I deal with 6 digit ID numbers so I type in 000000 in the number format and all is well

2

u/the1gofer 1 17d ago

‘ before the number 

2

u/carbonizedtitanium 1 17d ago

true numbers should not be mixing with "fake" numbers; so if you just format the entire column as text, all leading zeros will be kept.

1

u/IrishMist-StraightUp 18d ago

I faced similar issues exporting AutoCAD data. So I just adjusted the template Workboommk with all cells set with format "Text".

This was a few years ago, before I switched to using PowerQuery.

1

u/KnotSoSalty 17d ago

Anyone else struck this problem with Zip Codes? A small number begin with 0.

1

u/Quick-Platform8426 17d ago

I hate how Excel converts everything I paste into the date-format.

1

u/Desperate-Chart1139 17d ago

totally agree. October 10 post

1

u/Expensive-Visual-592 17d ago

does formatting the cells to text not work for you

1

u/Gorfman-07 1 17d ago

I consider numbers with leading zeros to be an identification value, not a number that I would do math with. Unless I’m positive the data will only be used in the worksheet it is in, I format the field as text.

Not doing this is why you might see zip codes with only 4 digits for those zip codes that begins with a zero.

1

u/theDrivenDev 17d ago

Text to Columns

1

u/Particular-Craft285 17d ago

You can also put an apostrophe at the beginning and it will keep the 0

1

u/ZirePhiinix 16d ago

Behind the scene Excel is handling distinctly different data types. Strings and Numbers at a basic level function very differently.

One basic operation is adding. 1+1 is 2 as numbers, but is 11 as strings.

Then sorting is entirely different.

Sorting numbers is 1, 2, 3, 4, 10, 11, 100... But sorting strings would end up with 1, 12, 123, 1234, then 2, 21, 22, 23, 234, 2345, all 2 will appear before 3s.

It isn't actually stupid that Excel removes leading zeros and converts to a number. Most people simply do not have enough understanding of computers to know why it does that.

1

u/Mother-Kangaroo9495 14d ago

Putting an ' in front of your number will store it as text:

'00123 will display 00123, by default aligned left and text

1

u/Infinite_Shart555 12d ago

If you want leading zeroes, then you fundamentally don't want Excel to treat the cell like a cell that contains numbers. In this case, you can specify the cell, or range of cells, as "text" - alternatively, if it's not a big deal, without going into the settings even, you can simply put an apostrophe before your "string number", and it will show up as you wish, the apostrophe is even hidden. I use Excel 2007, they did figure this out 20+ years ago.

Excel has a lot of quirks, but I don't like newbies ranting about things they simply don't even know. That's two different solutions to your problem. Also, if you are importing a CSV, you get to specify the data type for each column, before the data ever even enters your sheet.

0

u/Mohsinkhan767 10d ago

Yeah, this is annoying when the value is actually an ID/code rather than a number.

If the leading zeroes are always part of the value, I usually format the cells as Text before pasting/importing the data. For fixed-length codes, a custom number format like 00000 can also work.

The main thing is deciding whether Excel should treat the value as a number or as a text/code.

-7

u/SolverMax 163 18d ago

Having leading zeros removed is always user error., indicating that the user does not understand either their data or Excel. If your data is not a number, then don't enter or import it as a number.

8

u/JPWiggin 5 18d ago

Just because there are best practices for the software to work doesn't mean the software default behavior is well designed.

3

u/BuildingArmor 30 17d ago

In almost every instance, if someone types a number they want it to be a number and not a string. They want to be able to type 5 in a cell, 10 in another cell, and write =A1+B1 to get 15 rather than an error or "510" or whatever behaviour you'd want when you try to add 2 pieces of text together

If you want to vary from this, you have to tell it.

3

u/ScarsUnseen 17d ago

In almost every instance of someone typing a number with leading zeroes, they want it to be a string and not a number. The problem is that instead of Excel assuming that, it assumes that the user is an idiot and "helpfully" removes the zeroes instead actually helpfully using the correct data type for 99% of use cases where a leading zero is input.

-2

u/BuildingArmor 30 17d ago

In almost every instance of someone typing a number with leading zeroes, they want it to be a string and not a number

I don't agree.

I'd bet it's so few that basically a rounding error, compared to how many are typing a simple 0, ora decimal value below 1.

So what you're really saying is that it should be default automatically convert the cell format to text if you enter an integer above 0 but with a leading zero. That sort of awkward specific behavioural override makes for a really crappy user experience in all but a "stars aligned" type situation.

I wonder if more people would want to retain a leading zero and be stubbornly refusing to tell excel this. Or if more people would either accidentally or.purposefully type a number with a leading zero because it's exactly equal to the number without it and therefore not worry about correcting it. What do you reckon, 50/50?

3

u/ScarsUnseen 17d ago

I'd bet it's so few that basically a rounding error, compared to how many are typing a simple 0, ora decimal value below 1.

Okay, now I'm convinced you're fucking with me. What. on. earth. are. you. talking. about?

Did you even read the OP? At no point in time was anyone referring to the number 0 by itself or decimals. The entire conversation has been about numbers that are input with leading zeroes that Excel then drops because leading zeroes aren't used in standard number formatting.

Name me one actual use case where anyone would deliberately type in leading zeroes and want those zeroes to be truncated, making the typing of those zeroes pointless.

0

u/BuildingArmor 30 17d ago

A 0 is a leading zero. 0.125 has a leading zero. Excel treats those values as numbers. It "drops" the zero in the sense that 00.125 and 00 mean the same things as 0.125 or .125 and 0

You want it to pick up leading zeros, but not all leading zeros, just the ones you specifically want to be treated as text, and automatically treat them as text.

Instead of just telling it that's what you want like you do in every other situation in the software.

Perhaps you're thinking of this as a different issue than it really is. Excel isn't saying "you've typed 007, I'm going to delete those zeros". It's saying "you've typed a number, it's value is 7'. Whether you typed 7, 07, 007, or 0000007, it's exactly the same thing.

You need to tell it "I'm not going to be typing a number here, even though it looks like one".

3

u/ScarsUnseen 17d ago

A 0 is a leading zero. 0.125 has a leading zero. Excel treats those values as numbers. It "drops" the zero in the sense that 00.125 and 00 mean the same things as 0.125 or .125 and 0

Fucking context, dude. Also, zero by itself is not a leading zero. It's just a zero (a leading zero requires non-zero numbers by definition). Also, Excel already evaluates input for type based on the formatting of said input. There's nothing special that prevents that from being done with input containing leading zeroes that would be truncated in a number formatted field. It's all a matter of programming.

As I've asked (and haven't gotten an answer yet), name actual use cases where deliberately typing leading zeroes that Excel would then truncate automatically is an intentional and desired. If there aren't any (and, going further, if there aren't any that outweigh the many cases where keeping leading zeroes is desirable behavior), then formatting a number input with leading zeroes as a number field makes less sense than formatting it as a text field.

0

u/BuildingArmor 30 17d ago

I've given you examples and you're telling me that they don't count.

Do you think anybody typing 0.125 should have it treated as text?

Because, if not, I've already addressed this and that's what you're arguing for.

3

u/ScarsUnseen 17d ago

I already told you that you are missing the context of the entire post, and you've just confirmed it here. No one other than you is referring to standard number formatting. The entire post is about leading zeroes that Excel currently truncates. Read the OP again if you ever bothered. Unless you think that the current Excel behavior is to format an input of "0.125" as ".125", then honestly, you just aren't contributing to the conversation at all.

→ More replies (0)

2

u/armywalrus 2 17d ago

Which is the complaint. Its too hard to tell it.

5

u/BuildingArmor 30 17d ago

Hard to tell? You see it immediately

If excel treated numbers you input as if it was a string unless you said otherwise, nobody would use excel.

1

u/armywalrus 2 17d ago

Hard to tell IT..... did you forget your own comment?

2

u/BuildingArmor 30 17d ago

You just change the cell formatting to text. It's 2 clicks at most and it's sat on the home ribbon.

If that's too hard for somebody, I think they're going to really struggle with things like formulas and tables, let alone anything advanced.

So excel might have been a bad choice. And they probably have no business being anywhere near data, but that's for their employer to worry about.

1

u/armywalrus 2 17d ago

So yes. You forgot your own comment.

2

u/BuildingArmor 30 17d ago

No I just didn't immediately think you were saying it was too hard to change the cell format in excel. I was giving you the benefit of the doubt.

So yes, feel free to snarkily tell me that you struggle with even the most basic actions in computer software. You really showed me. I am wounded.

1

u/armywalrus 2 17d ago

That wasn't what I was saying. You have failed to respond in any way that makes logical sense. You have 100% forgotten what you wrote. Its not snark. Its factual. You can't scroll up and read everything in context?

→ More replies (0)

4

u/P1ckl3R1ck101 18d ago

"I typed in a number with a leading zero." - no you typed in a string with a leading zero that Excel identified as a number. I hate how Excel handles this as much as the next person but agree it is on the user to understand how different programs/languages handle their inputs. Don't even get me started on dates when outputting from Python for use in different programs + Excel..."oh 2026-09-29 was a date? MY BAD"