Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
m800afc
 
Posts: n/a
Default How do I force a leading zero character eg 07817

I am entring in order codes on a stock order sheet. The codes have 5 digits.
Some of them begin with 0 (zero). How do I force the cell to report the
correct number, ie 07817, and not 7817 as it is doing at the moment?

Thanks

Tony
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default How do I force a leading zero character eg 07817

Just enter the numbers preceeded by an apostrophe (single quote)
--
Gary''s Student


"m800afc" wrote:

I am entring in order codes on a stock order sheet. The codes have 5 digits.
Some of them begin with 0 (zero). How do I force the cell to report the
correct number, ie 07817, and not 7817 as it is doing at the moment?

Thanks

Tony

  #3   Report Post  
Posted to microsoft.public.excel.misc
David Biddulph
 
Posts: n/a
Default How do I force a leading zero character eg 07817

"m800afc" wrote in message
...
I am entring in order codes on a stock order sheet. The codes have 5
digits.
Some of them begin with 0 (zero). How do I force the cell to report the
correct number, ie 07817, and not 7817 as it is doing at the moment?


Format the cell as text before you enter the number.
--
David Biddulph


  #4   Report Post  
Posted to microsoft.public.excel.misc
jbrackett
 
Posts: n/a
Default How do I force a leading zero character eg 07817


I had a similar issue with data containing leading zeroes. Excel would
promptly clip them off making the use of lookups, etc... useless. Here
is what I did:
(Assuming you need a fixed length of 5 char)

A B C
1 NUM DESC FORMULA RESULT
2 1 apple =REPT("0",5-LEN(a2))&A2 = 00001
3 22 orange =REPT("0",5-LEN(a3))&A3 = 00022
4 304 pear =REPT("0",5-LEN(a4))&A4 = 00304

What it does:
=REPT("s",x) Repeats "s" (or whatever string), x times)
=LEN(a2) Returns the char count of a2

The combined formula repeats "0" for (5 - length of a2), &a2
concatenates the value of a2 to the end. Replace 5 with whatever fixed
length you need.

Regards and good luck!

Jay


--
jbrackett
------------------------------------------------------------------------
jbrackett's Profile: http://www.excelforum.com/member.php...o&userid=32577
View this thread: http://www.excelforum.com/showthread...hreadid=525226

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keeping leading 0's CLR Excel Discussion (Misc queries) 3 March 3rd 06 10:45 PM
Count occurrence of character within a cell Kelli Excel Discussion (Misc queries) 2 January 18th 06 02:20 PM
How do I force leading zeros in an Excel cell? EricKei Excel Discussion (Misc queries) 2 June 15th 05 08:28 PM
Concatenate & Force argument to End of String-(spsjp) SP Excel Worksheet Functions 3 April 2nd 05 03:37 PM
Leading zeros JC Excel Discussion (Misc queries) 9 February 1st 05 02:33 PM


All times are GMT +1. The time now is 11:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"