ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Leading zeros (https://www.excelbanter.com/excel-discussion-misc-queries/65820-leading-zeros.html)

mary

Leading zeros
 
How do I retain the leading zeros in an if statement eg if b3=b2 then b4+1
where b4 = 0001. The next number generated should be 0002 not 2.

Thanks
Mary

Ron Coderre

Leading zeros
 
If you set the number format for those cells to be 0000, they'll show the
leading zeros, but they won't actually be part of the value. Meaning that
the number 2 will display as 0002.

They you could use a variation of this formula:
=IF(B2=B3,B4+1,B4)

Alternatively, you could try working with this:
=IF(B2=B3,TEXT(--(B4)+1,"0000"),B4)

Which will actually create "numeric text" but treat it like a number. The
value will be the string 0002, not the number 2.

Something you can work with?

***********
Regards,
Ron

XL2002, WinXP-Pro


"mary" wrote:

How do I retain the leading zeros in an if statement eg if b3=b2 then b4+1
where b4 = 0001. The next number generated should be 0002 not 2.

Thanks
Mary



All times are GMT +1. The time now is 05:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com