ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Missing Zero (https://www.excelbanter.com/excel-programming/415462-missing-zero.html)

Beebolbod

Missing Zero
 

Hi,

Why when doing search and replace against variable xxx with a value such as
06 does xxx always end up as 6? I want to preserve the leading zero.
I've changed the format of the cells to no avail.

Any ideas?

BR

Rob

Beebolbod

Missing Zero
 
Thanks Rick,

I'm currently doing just that and it seems to be working when the vairable
is isolated in it's own cell.
I am however modifying this variable within a long line of other code which
is mixed with text/characters and numbers. Will this look to format only
numbers within a line of stuff?

BR

Rob

"Rick Rothstein (MVP - VB)" wrote:

Try clicking the Format button next to the "Replace with" field and set a
Custom Format of 00 there. After doing that, you can just specify 6 as the
"Replace with" entry as the Custom Format will handle adding the leading
zero for you.

Rick


"Beebolbod" wrote in message
...
Hi,

Why when doing search and replace against variable xxx with a value such
as
06 does xxx always end up as 6? I want to preserve the leading zero.
I've changed the format of the cells to no avail.

Any ideas?

BR

Rob




Rick Rothstein \(MVP - VB\)[_2539_]

Missing Zero
 
It looks like if you use 06 instead of just 6, then replacements inside of
text will preserve that leading zero because the replacement is pure text
for text... the Format is needed only to handle numbers by themselves
because numbers do not naturally support leading zeroes.

Rick


"Beebolbod" wrote in message
...
Thanks Rick,

I'm currently doing just that and it seems to be working when the vairable
is isolated in it's own cell.
I am however modifying this variable within a long line of other code
which
is mixed with text/characters and numbers. Will this look to format only
numbers within a line of stuff?

BR

Rob

"Rick Rothstein (MVP - VB)" wrote:

Try clicking the Format button next to the "Replace with" field and set a
Custom Format of 00 there. After doing that, you can just specify 6 as
the
"Replace with" entry as the Custom Format will handle adding the leading
zero for you.

Rick


"Beebolbod" wrote in message
...
Hi,

Why when doing search and replace against variable xxx with a value
such
as
06 does xxx always end up as 6? I want to preserve the leading zero.
I've changed the format of the cells to no avail.

Any ideas?

BR

Rob





Beebolbod

Missing Zero
 
Thanks Rick. Seems to work ok!

"Rick Rothstein (MVP - VB)" wrote:

It looks like if you use 06 instead of just 6, then replacements inside of
text will preserve that leading zero because the replacement is pure text
for text... the Format is needed only to handle numbers by themselves
because numbers do not naturally support leading zeroes.

Rick


"Beebolbod" wrote in message
...
Thanks Rick,

I'm currently doing just that and it seems to be working when the vairable
is isolated in it's own cell.
I am however modifying this variable within a long line of other code
which
is mixed with text/characters and numbers. Will this look to format only
numbers within a line of stuff?

BR

Rob

"Rick Rothstein (MVP - VB)" wrote:

Try clicking the Format button next to the "Replace with" field and set a
Custom Format of 00 there. After doing that, you can just specify 6 as
the
"Replace with" entry as the Custom Format will handle adding the leading
zero for you.

Rick


"Beebolbod" wrote in message
...
Hi,

Why when doing search and replace against variable xxx with a value
such
as
06 does xxx always end up as 6? I want to preserve the leading zero.
I've changed the format of the cells to no avail.

Any ideas?

BR

Rob






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

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