View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
[email protected] michael_fett@hotmail.com is offline
external usenet poster
 
Posts: 7
Default Fractions, Feet, Inches, & macros

That works! Thanks alot

"Toppers" wrote:

In your macro make this change:

NbrFeet = CInt(FeetIn)

I got result of 865 with D3 as input.

" wrote:

2 cells. One for feet(A1), one for inches(A2). A3=(A1+(A2/12))
-Ok lets do the samething again.
2 more cells. One for feet(B1), one for inches(B2). B3=(B1+(B2/12))
-One more time
2 more cells. One for feet(C1), one for inches(C2). C3=(C1+(C2/12))
-Finally D3=((A3+B3)-C3)

Now as far as I can tell everything works just fine. But I have a macro to
convert a decimal number into Feet and Inches:

Public Function LenText(FeetIn As Double)
Denominator = 32
NbrFeet = Fix(FeetIn)
InchIn = (FeetIn - NbrFeet) * 12
NbrInches = Fix(InchIn)
FracIn = (InchIn - NbrInches) * Denominator
Numerator = Application.WorksheetFunction.Round(FracIn, 0)
If Numerator = 0 Then
FracText = ""
ElseIf Numerator = Denominator Then
NbrInches = NbrInches + 1
FracText = ""
Else
Do
If Numerator = Application.WorksheetFunction.Even(Numerator) Then
Numerator = Numerator / 2
Denominator = Denominator / 2
Else
FracText = " " & Numerator & "/" & Denominator
Exit Do
End If
Loop
End If
LenText = NbrFeet & "' " & NbrInches & FracText & """"
End Function

Try;
A1 = 865
A2 = 2
B1 = 0
B2 = 6.5
C1 = 0
C2 = 8.5

If done correctly D3 will return 865. If the run the LenText marco on this
cell it returns 864' 12". If you type 865 in a blank cell and run the
LenText macro against it, it returns 865' 0".

What gives? This doesn't make any sence to me. Is the Macro corrupt or is
it something wrong with decimal places?

I realize this is a lot to process, but any help would be very useful.