View Single Post
  #8   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

This appears to be working much better. I can't thank you enough.

Just so I'm 100% clear on this. 3 is equal to the number of decimal places
it will round to? Correct?

"Toppers" wrote:

Hi,
try this in LENTEXT:

NbrFeet = Fix(Round(FeetIn, 3)) (Change the 3 if required)

I "found" your problems (because Cint rounds up).

" wrote:

I take that back. Its not working like I had hoped. I also have another
macro that converts 1' 0" to 1;

Public Function Feet(LenString As String)
Dim FootSign As Integer
Dim InchSign As Integer
Dim SpaceSign As Integer
Dim FracSign As Integer
Dim InchString As String
Dim Word2 As String
LenString = Application.WorksheetFunction.Trim(LenString)
On Error Resume Next
FootSign = Application.WorksheetFunction.Find("'", LenString)
If IsEmpty(FootSign) Or FootSign = 0 Then
Feet = 0
FootSign = 0
Else
Feet = Val(Left(LenString, FootSign - 1))
End If

If Len(LenString) = FootSign Then Exit Function
InchString = Application.WorksheetFunction.Trim(Mid(LenString, FootSign
+ 1))
InchSign = Application.WorksheetFunction.Find("""", InchString)
If Not IsEmpty(InchSign) Or InchSign = 0 Then
InchString = Application.WorksheetFunction.Trim(Left(InchString ,
InchSign - 1))
End If

SpaceSign = Application.WorksheetFunction.Find(" ", InchString)
If IsEmpty(SpaceSign) Or SpaceSign = 0 Then
FracSign = Application.WorksheetFunction.Find("/", InchString)
If IsEmpty(FracSign) Or FracSign = 0 Then
Feet = Feet + Val(InchString) / 12
Else
Feet = Feet + (Val(Left(InchString, FracSign - 1)) /
Val(Mid(InchString, FracSign + 1))) / 12
End If
Else
Feet = Feet + Val(Left(InchString, SpaceSign - 1)) / 12
Word2 = Mid(InchString, SpaceSign + 1)
FracSign = Application.WorksheetFunction.Find("/", Word2)
If IsEmpty(FracSign) Or FracSign = 0 Then
Feet = "VALUE!"
Else
If FracSign = 0 Then
Feet = "VALUE!"
Else
Feet = Feet + (Val(Left(Word2, FracSign - 1)) /
Val(Mid(Word2, FracSign + 1))) / 12
End If
End If
End If
End Function


If you use this macro in conjection with the the other, changing Fix to CInt
gives mixed results. So instead of doing what I discribed early use this to
convert the feet and inches. =LenText((Feet(D1))+(Feet(D2))-Feet(A5))