Trimming leading zero (0)

CripZZ23

New Member
Joined
Dec 22, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I have a filed with data similar to the following:

AA-01
AA-02
AA-02 (01)
AA-10
AA-10 (01)
AA-10 (12)

Essentially it is always two letters followed by a - then a number (1 or 2 digits, but possibly zero padded to the left), and optionally another 1 to 2 digits in ( ) that is also potentially zero padded to the left.

I would like to remove the leading zeros so that they look like the right column below:
AA-01 AA-1
AA-02 AA-2
AA-02 (01) AA-2 (1)
AA-10 AA-10
AA-10 (01) AA-10 (1)
AA-10 (12) AA-10 (12)

I'm struggling - any help?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Assuming your cell values are in A1:A6, you could do something like this:

Excel Formula:
=LET(cellValues,A1:A6,TRIM(TEXTSPLIT(cellValues,"-")&"-"&LET(firstNumbers,TEXTSPLIT(TEXTAFTER(cellValues,"-")," "),IF(LEFT(firstNumbers,1)="0",RIGHT(firstNumbers,1),firstNumbers))&" "&LET(lastNumbers,IFNA(TEXTAFTER(cellValues," "),""),IF(LEFT(lastNumbers,2)="(0","("&RIGHT(lastNumbers,2),lastNumbers))))

But Rorys is way easier and more efficient.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

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