View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
DMB DMB is offline
external usenet poster
 
Posts: 14
Default Mod function not working right?

Function LumberLabel(width As Range, height As Range, material As Range,
spacing As Range) As String

Dim myWidth As String
Dim myHeight As String
Dim myMaterial As String
Dim mySpacing As String
myWidth = width
myHeight = height
myMaterial = material
mySpacing = spacing

'Material type: DF #2, DF#1, PSL, ect.

'Add spacing ie @ 16" O.C. , @ 25" O.C.
If mySpacing < 0 And mySpacing < "" Then mySpacing = " @ " & mySpacing
& " in oc"

'Lumber sizing
Dim x As Integer
'x = width Mod 0.5

Dim aWidth As Double
aWidth = Round(myWidth)
If ((aWidth / 2) - (aWidth \ 2)) < 0 Then
LumberLabel = "1. Will not work (myWidth / 2) = " & (myWidth / 2) &
" and myWidth \ 2 = " & (myWidth \ 2)
'ElseIf x < 0 Then
LumberLabel = "2. x < 0 = " & width Mod 0.5
Else
LumberLabel = myWidth & " x " & myHeight & myMaterial & mySpacing
End If
'This is giving me the error
'width Mod 0.5
'and this
LumberLabel = "2. = " & 19.6 Mod 3.2

'A = 19 Mod 6.7

End Function