Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Adding recognised Zeros


Hi All

I need to add zeros to the beginning of numbers of less than 13 digits.

I've been using the custom format method 0000000000000 , but find it
'forgets' the zeros when counting the length of the cell contents. This
is causing errors.

I'm now using

=IF(LEN(A2)=12,("0"&A2),A2)

This correctly produces a cell which has a zero added when the length is
12 , and then correctly shows 13 digits when the length is queried.

Can someone suggest an amended formula to add 2 zeros when length is
11 , 3 zeros when length is 10 , 4 zeros when length is 9 and 5 zeroes
when length is 8?

Trying to work these into a single formula is beyond me , but I'm hoping
someone can help.

Grateful for any advice.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Adding recognised Zeros

Hi Colin,

Am Thu, 28 Nov 2013 17:15:25 +0000 schrieb Colin Hayes:

I've been using the custom format method 0000000000000 , but find it
'forgets' the zeros when counting the length of the cell contents. This
is causing errors.


why does this not working for you? Or do you need really 13 digits
number and not only the format?

I'm now using

=IF(LEN(A2)=12,("0"&A2),A2)


try:
=REPT(0,13-LEN(A2))&A2


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Adding recognised Zeros

Hi Colin,

Am Thu, 28 Nov 2013 18:26:45 +0100 schrieb Claus Busch:

=REPT(0,13-LEN(A2))&A2


or try:
=TEXT(A2;"0000000000000")
Copy the column with the formulas and paste it back as values


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Adding recognised Zeros

try:
=REPT(0,13-LEN(A2))&A2


Hi Claus

OK Thanks again. This works perfectly. I do need 13 solid digit numbers
and not just format.

BTW I find I have a couple of 14 digit numbers in my column which give
#VALUE! Errors. Is there a way to ignore these numbers when running the
REPT formula?


Best Wishes


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Adding recognised Zeros

Hi Colin,

Am Thu, 28 Nov 2013 19:13:23 +0000 schrieb Colin Hayes:

BTW I find I have a couple of 14 digit numbers in my column which give
#VALUE! Errors. Is there a way to ignore these numbers when running the
REPT formula?


try:
=REPT(0,MAX(LEN(A2),13)-LEN(A2))&A2


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Adding recognised Zeros

In article , Claus Busch
writes
Hi Colin,

Am Thu, 28 Nov 2013 19:13:23 +0000 schrieb Colin Hayes:

BTW I find I have a couple of 14 digit numbers in my column which give
#VALUE! Errors. Is there a way to ignore these numbers when running the
REPT formula?


try:
=REPT(0,MAX(LEN(A2),13)-LEN(A2))&A2


Regards
Claus B.


Hi Claus

OK that's entirely perfect.

Thanks Claus.

^_^
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
adding zeros to numbers in columns Tim[_7_] Excel Discussion (Misc queries) 1 October 18th 07 03:39 AM
Adding leading zeros SITCFanTN Excel Programming 3 July 10th 07 07:12 PM
adding zeros to a cell DD Excel Discussion (Misc queries) 3 April 29th 05 07:56 PM
Adding Leading Zeros to Text Jenn Excel Discussion (Misc queries) 4 January 12th 05 06:51 PM
Adding zeros abxy[_43_] Excel Programming 2 April 6th 04 05:53 PM


All times are GMT +1. The time now is 01:15 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"