Remove leading zero within a text field

bflanagan

New Member
Joined
Dec 8, 2015
Messages
10
Hello,

I have a list of codes I need to removed the leading zero from. However, I only want to remove the leading zero and not all of them.

I have been looking for a while but cant seem to figure it out. Any ideas?

The codes look like this:

AB01
AB02
AB03
AB05
AB10

<tbody>
</tbody>
and I need them to look like this:

AB1
AB2
AB3
AB5
AB10


Thanks!

<tbody>
</tbody>
 
It would have helped to get all those variations up front in the original post..

Try
=SUBSTITUTE(LEFT(A1,MIN(FIND({1,2,3,4,5,6,7,8,9},A1&15^12))-1),0,"")&RIGHT(A1,LEN(A1)-MIN(FIND({1,2,3,4,5,6,7,8,9},A1&15^12))+1)
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Awesome - works like a treat! Thanks for your help!


how about

Excel 2012
AB
1AB01AB1
2AB02AB2
3AB03AB3
4AB05AB5
5AB10AB10
6AB11AB11
7AB12AB12
8AB13AB13
9AB14AB14
10AB15AB15

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
B1=IFERROR(IF(FIND(0,A1)<LEN(A1),SUBSTITUTE(A1,0,""),A1),A1)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Hi Jonmo1,

That worked perfectly - thank you!

Apologies, I only noticed a few had letters after the numbers when I ran your initial formula.

Thanks agin for your help!



It would have helped to get all those variations up front in the original post..

Try
=SUBSTITUTE(LEFT(A1,MIN(FIND({1,2,3,4,5,6,7,8,9},A1&15^12))-1),0,"")&RIGHT(A1,LEN(A1)-MIN(FIND({1,2,3,4,5,6,7,8,9},A1&15^12))+1)
 
Upvote 0
you could have as well select the entire column and hit ctrl h. Find what = 0 Replace with= leave blank
 
Last edited:
Upvote 0
There are also sometimes 3 characters before yes.

Here are the different types of codes:


A01
AB01
ABC01
A01B

Also, some codes are already in the correct format e.g.

A1
AB1
ABC1
A1B

Another option :

=IFERROR(REPLACE(A1,FIND(0,A1&0),MIN(FIND({1,2,3,4,5,6,7,8,9},A1&1/17))-FIND(0,A1&0),""),A1)
 
Upvote 0
This formula appears to work correctly for all the possible variations mentioned so far (including A202 and A010 and their variations)...

=REPLACE(A1,FIND(0,A1&0),ISERR(MID(A1,FIND(0,A1&0)-1,1)+0),"")
 
Upvote 0
This formula appears to work correctly for all the possible variations mentioned so far (including A202 and A010 and their variations)...

=REPLACE(A1,FIND(0,A1&0),ISERR(MID(A1,FIND(0,A1&0)-1,1)+0),"")
Of course, it will not remove all leading zeroes if there are more than one of them (AB001 for example becomes AB01 with my formula)... we need the OP to tell us if that is a possibility or not.
 
Upvote 0

Forum statistics

Threads
1,215,014
Messages
6,122,697
Members
449,092
Latest member
snoom82

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top