Forum Discussion
gressco
Jun 10, 2021Copper Contributor
Leading zeros
Good Morning, I lost my leading 0's on all of my 5 digit product numbers. Is there an If statement that can find anything with a 4 digit number to add a leading 0? Thanks!
- Jun 10, 2021Not sure exactly what you want your end product to look like, do you want it to be all text? Would something like this work? This is unaffected if you convert cell format to text. =IF(LEN(A2)=4,0&A2,A2)
When I try the REPT formula on my end it doesn't change any of the calculations ran off of it.
DKoontz
Jun 10, 2021Iron Contributor
Hi! Assuming your prduct numbers are in A:A, this will work.
=REPT(0,5-LEN(A9))&A9
It adds repeating zeroes for any missing characters up to 5 characters, then adds that to the front of the same cell.
=REPT(0,5-LEN(A9))&A9
It adds repeating zeroes for any missing characters up to 5 characters, then adds that to the front of the same cell.
gressco
Jun 10, 2021Copper Contributor
Thanks! I am still doing something wrong, as this is changing the value of the cell - its calculating a value. I just want to put a 0 in front of the current number. Should I have made them text fields first?
thanks for your help!
thanks for your help!
- DKoontzJun 10, 2021Iron ContributorNot sure exactly what you want your end product to look like, do you want it to be all text? Would something like this work? This is unaffected if you convert cell format to text. =IF(LEN(A2)=4,0&A2,A2)
When I try the REPT formula on my end it doesn't change any of the calculations ran off of it.