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>
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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.

AB01AB1
AB02AB2
AB03AB3
AB05AB5
AB10AB10
AB11#VALUE!
AB12#VALUE!
AB13#VALUE!
AB14#VALUE!
AB15#VALUE!



<colgroup><col><col></colgroup><tbody>
</tbody>
 
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.

AB01AB1
AB02AB2
AB03AB3
AB05AB5
AB10AB10
AB11#VALUE!
AB12#VALUE!
AB13#VALUE!
AB14#VALUE!
AB15#VALUE!



<colgroup><col><col></colgroup><tbody>
</tbody>

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,214,393
Messages
6,119,261
Members
448,880
Latest member
aveternik

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