The formatted display of fractional measurements in Excel leaves a lot to be desired. This example and the formulas shown below were generously provided by Bernie Deitrick as a followup to a posting 2000-08-04 in the microsoft.public.excel.misc newsgroup.
These do, of course, require a cell on the worksheet for the value and another for the text formatting.
A | B | C | D | E | |
1 | 26.0827 | Fr: Simple Decimal To: Simple Fractions |
Fr: Decimal Inches To: Fractional Inches |
Fr: Decimal Feet To: Feet and Fractional Inches |
Fr: Decimal Inches To: Feet and Fractional Inches |
2 | Down to 4ths | 26 | 26" | 26' 1" | 2' 2" |
3 | Down to 8ths | 26 1/8 | 26 1/8" | 26' 1" | 2' 2 1/8" |
4 | Down to 16ths | 26 1/16 | 26 1/16" | 26' 1" | 2' 2 1/16" |
5 | Down to 32nds | 26 3/32 | 26 3/32" | 26' 1" | 2' 2 3/32" |
6 | Down to 64ths | 26 5/64 | 26 5/64" | 26' 0 63/64" | 2' 2 5/64" |
7 | Down to 128ths | 26 11/128 | 26 11/128" | 26' 0 127/128" | 2' 2 11/128" |
8 | |||||
9 | This spreadsheet gives formulas used to display decimal values given in cell A1 as fractions with the denominator being variable and chosen as the smallest among 2,4,8,16.... as appropriate. Equations developed by Bernie Deitrick mailto:deitbe@consumer.org |
b1 | Fr: Simple Decimal To: Simple Fractions | |
b2 | 26 | =TEXT(A1,"0"&IF(ABS(A1-ROUND(A1,0))>1/8," 0/"&CHOOSE(ROUND(MOD(A1,1)*4,0),4,2,4),"")) |
b3 | 26 1/8 | =TEXT(A1,"0"&IF(ABS(A1-ROUND(A1,0))>1/16," 0/"&CHOOSE(ROUND(MOD(A1,1)*8,0),8,4,8,2,8,4,8),"")) |
b4 | 26 1/16 | =TEXT(A1,"0"&IF(ABS(A1-ROUND(A1,0))>1/32," 0/"&CHOOSE(ROUND(MOD(A1,1)*16,0),16,8,16,4,16,8,16,2,16,8,16,4,16,8,16),"")) |
b5 | 26 3/32 | =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/MAX(2,4,8,16,32)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(A1*{2,4,8,16,32},0)-A1*{2,4,8,16,32})/{2,4,8,16,32}),ABS(ROUND(A1*{2,4,8,16,32},0)-A1*{2,4,8,16,32})/{2,4,8,16,32},0),2,4,8,16,32),"")) |
b6 | 26 5/64 | =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/MAX(2,4,8,16,32,64)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(A1*{2,4,8,16,32,64},0)-A1*{2,4,8,16,32,64})/{2,4,8,16,32,64}),ABS(ROUND(A1*{2,4,8,16,32,64},0)-A1*{2,4,8,16,32,64})/{2,4,8,16,32,64},0),2,4,8,16,32,64),"")) |
b7 | 26 11/128 | =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/MAX(2,4,8,16,32,64,128)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(A1*{2,4,8,16,32,64,128},0)-A1*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128}),ABS(ROUND(A1*{2,4,8,16,32,64,128},0)-A1*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128},0),2,4,8,16,32,64,128),"")) |
| | |
c1 | Fr: Decimal Inches To: Fractional Inches | |
c2 | 26" | =TEXT(A1,"0"&IF(ABS(A1-ROUND(A1,0))>1/8," 0/"&CHOOSE(ROUND(MOD(A1,1)*4,0),4,2,4),""))&"""" |
c3 | 26 1/8" | =TEXT(A1,"0"&IF(ABS(A1-ROUND(A1,0))>1/16," 0/"&CHOOSE(ROUND(MOD(A1,1)*8,0),8,4,8,2,8,4,8),""))&"""" |
c4 | 26 1/16" | =TEXT(A1,"0"&IF(ABS(A1-ROUND(A1,0))>1/32," 0/"&CHOOSE(ROUND(MOD(A1,1)*16,0),16,8,16,4,16,8,16,2,16,8,16,4,16,8,16),""))&"""" |
c5 | 26 3/32" | =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/MAX(2,4,8,16,32)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(A1*{2,4,8,16,32},0)-A1*{2,4,8,16,32})/{2,4,8,16,32}),ABS(ROUND(A1*{2,4,8,16,32},0)-A1*{2,4,8,16,32})/{2,4,8,16,32},0),2,4,8,16,32),""))&"""" |
c6 | 26 5/64" | =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/MAX(2,4,8,16,32,64)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(A1*{2,4,8,16,32,64},0)-A1*{2,4,8,16,32,64})/{2,4,8,16,32,64}),ABS(ROUND(A1*{2,4,8,16,32,64},0)-A1*{2,4,8,16,32,64})/{2,4,8,16,32,64},0),2,4,8,16,32,64),""))&"""" |
c7 | 26 11/128" | =TEXT(A1,"0" &IF(ABS(A1-ROUND(A1,0))>1/MAX(2,4,8,16,32,64,128)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(A1*{2,4,8,16,32,64,128},0)-A1*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128}),ABS(ROUND(A1*{2,4,8,16,32,64,128},0)-A1*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128},0),2,4,8,16,32,64,128),""))&"""" |
| | |
d1 | Fr: Decimal Feet To: Feet and Fractional Inches | |
d2 | 26' 1" | =IF(A1>=1,INT(A1)&"' ","")&TEXT(MOD(A1,1)*12,"0"&IF(ABS(MOD(A1,1)*12-ROUND(MOD(A1,1)*12,0))>1/8," 0/"&CHOOSE(ROUND(MOD(MOD(A1,1)*12,1)*4,0),4,2,4),""))&"""" |
d3 | 26' 1" | =IF(A1>=1,INT(A1)&"' ","") & TEXT(MOD(A1,1)*12,"0"&IF(ABS(MOD(A1,1)*12-ROUND(MOD(A1,1)*12,0))>1/16," 0/"&CHOOSE(ROUND(MOD(MOD(A1,1)*12,1)*8,0),8,4,8,2,8,4,8),"")) &"""" |
d4 | 26' 1" | =IF(A1>=1,INT(A1)&"' ","") & TEXT(MOD(A1,1)*12,"0"&IF(ABS(MOD(A1,1)*12-ROUND(MOD(A1,1)*12,0))>1/32," 0/"&CHOOSE(ROUND(MOD(MOD(A1,1)*12,1)*16,0),16,8,16,4,16,8,16,2,16,8,16,4,16,8,16),"")) &"""" |
d5 | 26' 1" | =IF(A1>=1,INT(A1)&"' ","") & TEXT(MOD(A1,1)*12,"0" &IF(ABS(MOD(A1,1)*12-ROUND(MOD(A1,1)*12,0))>1/MAX(2,4,8,16,32)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(MOD(A1,1)*12*{2,4,8,16,32},0)-MOD(A1,1)*12*{2,4,8,16,32})/{2,4,8,16,32}),ABS(ROUND(MOD(A1,1)*12*{2,4,8,16,32},0)-MOD(A1,1)*12*{2,4,8,16,32})/{2,4,8,16,32},0),2,4,8,16,32),""))&"""" |
d6 | 26' 0 63/64" | =IF(A1>=1,INT(A1)&"' ","") & TEXT(MOD(A1,1)*12,"0" &IF(ABS(MOD(A1,1)*12-ROUND(MOD(A1,1)*12,0))>1/MAX(2,4,8,16,32,64)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(MOD(A1,1)*12*{2,4,8,16,32,64},0)-MOD(A1,1)*12*{2,4,8,16,32,64})/{2,4,8,16,32,64}),ABS(ROUND(MOD(A1,1)*12*{2,4,8,16,32,64},0)-MOD(A1,1)*12*{2,4,8,16,32,64})/{2,4,8,16,32,64},0),2,4,8,16,32,64),""))&"""" |
d7 | 26' 0 127/128" | =IF(A1>=1,INT(A1)&"' ","") & TEXT(MOD(A1,1)*12,"0" &IF(ABS(MOD(A1,1)*12-ROUND(MOD(A1,1)*12,0))>1/MAX(2,4,8,16,32,64,128)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(MOD(A1,1)*12*{2,4,8,16,32,64,128},0)-MOD(A1,1)*12*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128}),ABS(ROUND(MOD(A1,1)*12*{2,4,8,16,32,64,128},0)-MOD(A1,1)*12*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128},0),2,4,8,16,32,64,128),"")) & """" |
| | |
e1 | Fr: Decimal Inches To: Feet and Fractional Inches | |
e2 | 2' 2" | =INT(A1/12)&"' " &TEXT(MOD(A1,12),"0"&IF(ABS(MOD(A1,12)-ROUND(MOD(A1,12),0))>1/8," 0/"&CHOOSE(ROUND(MOD(MOD(A1,12),1)*4,0),4,2,4),""))&"""" |
e3 | 2' 2 1/8" | =INT(A1/12)&"' " & TEXT(MOD(A1,12),"0"&IF(ABS(MOD(A1,12)-ROUND(MOD(A1,12),0))>1/16," 0/"&CHOOSE(ROUND(MOD(MOD(A1,12),1)*8,0),8,4,8,2,8,4,8),"")) & """" |
e4 | 2' 2 1/16" | =INT(A1/12)&"' " & TEXT(MOD(A1,12),"0"&IF(ABS(MOD(A1,12)-ROUND(MOD(A1,12),0))>1/32," 0/"&CHOOSE(ROUND(MOD(MOD(A1,12),1)*16,0),16,8,16,4,16,8,16,2,16,8,16,4,16,8,16),"")) & """" |
e5 | 2' 2 3/32" | =INT(A1/12)&"' " & TEXT(MOD(MOD(A1,12),12),"0"&IF(ABS(MOD(MOD(A1,12),12)-ROUND(MOD(MOD(A1,12),12),0))>1/64," 0/"&CHOOSE(ROUND(IF(MOD(MOD(MOD(A1,12),12),1)-0.5>0,MOD(MOD(MOD(A1,12),12),1)-0.5,MOD(MOD(MOD(A1,12),12),1))*32,0)+1,2,32,16,32,8,32,16,32,4,32,16,32,8,32,16,32,2),""))& """" |
e6 | 2' 2 5/64" | =INT(A1/12)&"' " &TEXT(MOD(A1,12),"0" &IF(ABS(MOD(A1,12)-ROUND(MOD(A1,12),0))>1/MAX(2,4,8,16,32,64)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(MOD(A1,12)*{2,4,8,16,32,64},0)-MOD(A1,12)*{2,4,8,16,32,64})/{2,4,8,16,32,64}),ABS(ROUND(MOD(A1,12)*{2,4,8,16,32,64},0)-MOD(A1,12)*{2,4,8,16,32,64})/{2,4,8,16,32,64},0),2,4,8,16,32,64),""))&"""" |
e7 | 2' 2 11/128" | =INT(A1/12)&"' " & TEXT(MOD(A1,12),"0" &IF(ABS(MOD(A1,12)-ROUND(MOD(A1,12),0))>1/MAX(2,4,8,16,32,64,128)/2, " 0/"&CHOOSE(MATCH(MIN(ABS(ROUND(MOD(A1,12)*{2,4,8,16,32,64,128},0)-MOD(A1,12)*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128}),ABS(ROUND(MOD(A1,12)*{2,4,8,16,32,64,128},0)-MOD(A1,12)*{2,4,8,16,32,64,128})/{2,4,8,16,32,64,128},0),2,4,8,16,32,64,128),""))&"""" |
A12: B2
B12: (pasted from B2)
C12: =GetFormula(indirect(A12))
The original section was converted to HTML with XL2HTMLX, and the formulas section was converted to HTML with XL2HTML with macros described on my HTML page.
Visit [my Excel home page] [Index page] [Excel Onsite Search] [top of this page]
Presentation in HTML format by David McRitchie mailto:DMcRitchie@msn.com.
Appreciative comments should be directed to Bernie Deitrick mailto:deitbe@consumer.org for the content.