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:

[TABLE="width: 64"]
<tbody>[TR]
[TD="class: xl65, width: 64"]AB01[/TD]
[/TR]
[TR]
[TD="class: xl65"]AB02[/TD]
[/TR]
[TR]
[TD="class: xl65"]AB03[/TD]
[/TR]
[TR]
[TD="class: xl65"]AB05[/TD]
[/TR]
[TR]
[TD="class: xl65"]AB10
[/TD]
[/TR]
</tbody>[/TABLE]
and I need them to look like this:

[TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]AB1[/TD]
[/TR]
[TR]
[TD]AB2[/TD]
[/TR]
[TR]
[TD]AB3[/TD]
[/TR]
[TR]
[TD]AB5[/TD]
[/TR]
[TR]
[TD]AB10


Thanks![/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Welcome to the board.

Try this assuming the first part is always 2 characters before the numbers.

=LEFT(A1,2)&RIGHT(A1,LEN(A1)-2)+0
 
Upvote 0
try if this little trick works for you or not


Excel 2012
ABC
1AB01AB1
2AB02AB2
3AB03AB3
4AB05AB5
5AB10AB10
Sheet2
Cell Formulas
RangeFormula
C1=IF(FIND(0,A1)A1),SUBSTITUTE(A1,0,""),A1)
 
Upvote 0
Thanks Jonmo1, that worked really well!

Only problem is a few of my codes only have 1 character before the leading zero. Is there a way to take this into account?

Thanks
 
Upvote 0
Are there any other variations?
Is it always either 1 or 2 characters before the first number, never 3 or more?
 
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
 
Upvote 0
Try

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

This worked really well! However any data that was already correct (i.e. without the leading zero) fails.

E.g.

[TABLE="width: 168"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]AB01[/TD]
[TD]AB1[/TD]
[/TR]
[TR]
[TD]AB02[/TD]
[TD]AB2[/TD]
[/TR]
[TR]
[TD]AB03[/TD]
[TD]AB3[/TD]
[/TR]
[TR]
[TD]AB05[/TD]
[TD]AB5[/TD]
[/TR]
[TR]
[TD]AB10[/TD]
[TD]AB10[/TD]
[/TR]
[TR]
[TD]AB11[/TD]
[TD="align: center"]#VALUE![/TD]
[/TR]
[TR]
[TD]AB12[/TD]
[TD="align: center"]#VALUE![/TD]
[/TR]
[TR]
[TD]AB13[/TD]
[TD="align: center"]#VALUE![/TD]
[/TR]
[TR]
[TD]AB14[/TD]
[TD="align: center"]#VALUE![/TD]
[/TR]
[TR]
[TD]AB15[/TD]
[TD="align: center"]#VALUE!


[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Works really well! Thanks.

It fails on codes where there is a letter after the code (i.e. AB1C), however as there aren't many of these I can just manually update them. Thanks!!
 
Upvote 0
Thanks AlanY!

This worked really well! However any data that was already correct (i.e. without the leading zero) fails.

E.g.

[TABLE="width: 168"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]AB01[/TD]
[TD]AB1[/TD]
[/TR]
[TR]
[TD]AB02[/TD]
[TD]AB2[/TD]
[/TR]
[TR]
[TD]AB03[/TD]
[TD]AB3[/TD]
[/TR]
[TR]
[TD]AB05[/TD]
[TD]AB5[/TD]
[/TR]
[TR]
[TD]AB10[/TD]
[TD]AB10[/TD]
[/TR]
[TR]
[TD]AB11[/TD]
[TD="align: center"]#VALUE![/TD]
[/TR]
[TR]
[TD]AB12[/TD]
[TD="align: center"]#VALUE![/TD]
[/TR]
[TR]
[TD]AB13[/TD]
[TD="align: center"]#VALUE![/TD]
[/TR]
[TR]
[TD]AB14[/TD]
[TD="align: center"]#VALUE![/TD]
[/TR]
[TR]
[TD]AB15[/TD]
[TD="align: center"]#VALUE!


[/TD]
[/TR]
</tbody>[/TABLE]

how about


Excel 2012
AB
1AB01AB1
2AB02AB2
3AB03AB3
4AB05AB5
5AB10AB10
6AB11AB11
7AB12AB12
8AB13AB13
9AB14AB14
10AB15AB15
Sheet2
Cell Formulas
RangeFormula
B1=IFERROR(IF(FIND(0,A1)A1),SUBSTITUTE(A1,0,""),A1),A1)
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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