Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88868

Add leading 0 after the dash (-) but before the numbers

$
0
0

I have a formula that adds a 0 before the numbers 1-9 if they don't have one.

Old..................New

D-8..................D-08

FE-09..............FE-09

I-18..................I-18

P-1..................P-01

FG-08A...........FG-08

=LEFT(A1,FIND("-",A1))&TEXT(MID(A1,FIND("-",A1)+1,2),"00")

However, for values like FG-08A, I do not want it to clear the A at the end. So if it's FG-08A, the result would be FG-08A (remain unchanged). If it's FG-8A, it would be FG-08A (adds the leading 0 but keeps the "A").


Viewing all articles
Browse latest Browse all 88868


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>