Re: Add 0 to start of number if length is less than 5
To borrow from Lois Lowry's "The Giver", can we be very precise in our language? When you talk about "adding a 0 character to the left of a number" exactly what are you wanting to happen -- just display the number with those insignificant zeroes while the underlying value stays the same, or do you need to convert the number to a text string with those zeroes as part of the cell value? I notice that all of the proposed solutions are changing the number formatting so that the number 901 looks like 0901, but the cell's value is still 901. Do you need the cell value to stay 901, or do you need the cell's value to become the text string "0901"?
Originally Posted by shg
Mathematics is the native language of the natural world. Just trying to become literate.
Re: Add 0 to start of number if length is less than 5
When the number 901 becomes the text string "0901" what will then happen? We frequently encounter issues with numbers stored as text. Most of the time, the solution involves storing numbers as numbers. Converting numbers to text shouldn't be overly difficult, but it could be valuable to think through exactly how you are going to work with these "numbers stored as text" and otherwise how you are interacting with the spreadsheet to be sure that storing numbers as text is the best solution.
Re: Add 0 to start of number if length is less than 5
Hi MrShorty.
So the numbers in this table are then used for a lookup for data from elsewhere. Basically the data from elsewhere shows the numbers as 0901 or 01901, whereas the data that is shown in the attached file shows the numbers as 901 or 1901 etc.
Re: Add 0 to start of number if length is less than 5
You say that the data from elsewhere "shows" numbers as 0901 or 01901. Does this mean that the numbers are stored as text in this other location, or are they the number 901 formatted as "0000" or 1901 formatted as "00000"? Or are these data from elsewhere not even in a spreadsheet? How are you performing the lookup operation (Excel lookup function or something else)? Assuming the "data from elsewhere" is a number stored as text, would it be preferred to convert that to a real number? It often doesn't matter whether you search for numbers stored as numbers or numbers stored as text as long as you are consistent, which often leads to a decision as a programmer whether you will find it easier to consistently store everything as text or consistently store everything as number.
Good Luck...
I don't presume to know what I am doing, however, just like you, I too started somewhere...
One-day, One-problem at a time!!!
If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
Also....Add a comment if you like!!!!
And remember...Mark Thread as Solved...
Excel Forum Rocks!!!
Bookmarks