removing zeroes almost perfect

P

pat67

Hi I am using this to convert BHQ0009540 to C9540

=CONCATENATE("C",MID(RIGHT(B2,7),SEARCH(LEFT(SUBSTITUTE(RIGHT(B2,7),"0",""),
1),RIGHT(B2,7)),25))

the issue is sometimes i need a leading 0 like converting LPB0000385
to C0385. using the above I get C385.

I am at a loss. any ideas?

Thanks
 
D

David Biddulph

Hi I am using this to convert BHQ0009540 to C9540

=CONCATENATE("C",MID(RIGHT(B2,7),SEARCH(LEFT(SUBSTITUTE(RIGHT(B2,7),"0",""),
1),RIGHT(B2,7)),25))

the issue is sometimes i need a leading 0 like converting LPB0000385
to C0385. using the above I get C385.

I am at a loss. any ideas?

Thanks

="C"&TEXT(RIGHT(B2,7),"0000") if this suits the input format.
 
R

Rick Rothstein

="C"&TEXT(RIGHT(B2,7),"0000") if this suits the input format.

If you do that formula this way instead...

=TEXT(RIGHT(B2,7),"C0000")

then you will be able to copy it down through Column B cells that are blank
and not end up printing out that lone "C" character.

Rick Rothstein (MVP - Excel)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top