Reputation: 117
I have a set of locations with the following naming convention:
I want to change all of the KP values so that there are 3 digits before the decimal place, e.g.:
Can anyone think of a way to do this that doesn't involve 10 nested substitute functions?
Upvotes: 0
Views: 35
Reputation: 51998
If Your strings are in A1:A3
, enter this in B1
and copy down:
=LEFT(A1,3) & REPT("0",7 - FIND(".",A1)) & RIGHT(A1,LEN(A1)- 3)
Upvotes: 3
Reputation:
Try,
=TRIM(LEFT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1))&TEXT(VALUE(MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1),LEN(A1)))," 000.0# ")&MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)*2,LEN(A1))&MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)*3,LEN(A1)))
Upvotes: 1