Forum Discussion

gcf1956's avatar
gcf1956
Copper Contributor
Nov 23, 2020
Solved

Format number for fixed length field

Dear Helper, I have a 7-character field, which must receive a number.  The length of the field is fixed: 7 characters.  For instance, the field is located from column 10 to 16 (inclusive) as in the ...
  • HansVogelaar's avatar
    Nov 23, 2020

    gcf1956 

    Lets say you have a number such as 347.2952 in cell A1.

    Enter the following formula in B1:

     

    ="123456789"&TEXT(A1,IF(A1<0,""," ")&REPT("0",MAX(INT(LOG(ABS(A1)))+1,0))&"."&REPT("0",5-MAX(INT(LOG(ABS(A1)))+1,0)))&"7890123"

     

    This can be filled down.

    Warning: the number in A1 must have at most 5 digits before the decimal point.

    12345.678 will work, but 123456.78 won't.

Resources