Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DMB DMB is offline
external usenet poster
 
Posts: 14
Default Mod function not working right?

this formula is giving me an error. I need the remainder. Am I doing this
wrong?

26 Mod 3
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Mod function not working right?

from the immediate window:

? 26 Mod 3
2


seems to work fine.

--
Regards,
Tom Ogilvy


"DMB" wrote in message
...
this formula is giving me an error. I need the remainder. Am I doing this
wrong?

26 Mod 3



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Mod function not working right?

Hard to know if you're doing it wrong, since you don't say what you're
trying to do.

Mod is an operator, so it only makes sense in an assignment statement.
For instance:

a = 26 Mod 3

returns 2 to the variable a.

A bare

26 Mod 3

doesn't make sense - it's like putting the number 2 as a statement.

In article ,
DMB wrote:

this formula is giving me an error. I need the remainder. Am I doing this
wrong?

26 Mod 3

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 222
Default Mod function not working right?

Try =MOD(26,3)

"DMB" wrote:

this formula is giving me an error. I need the remainder. Am I doing this
wrong?

26 Mod 3

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Mod function not working right?

What answer are you expecting?

Tim

"DMB" wrote in message
...
this formula is giving me an error. I need the remainder. Am I doing this
wrong?

26 Mod 3





  #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
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Mod function not working right?

? 19.6 Mod 3.2
2

the equivalent of 20 mod 3

which is the expected behavior as stated in help on the MOD function. So
you still didn't answer what you expect?

width mod 0.5 gives me a divide by zero, so 0.5 is rounded down to 0 I
suspect. (it is probably stored as .49999999999)

I don't think the mod operator will work for you.
--
Regards,
Tom Ogilvy

"DMB" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ISBLANK function not working when cell is blank dut to function re mcmilja Excel Discussion (Misc queries) 9 May 7th 23 03:43 AM
IF Function not working Loren Excel Discussion (Misc queries) 7 February 26th 07 09:27 PM
Function not working donnaK Excel Worksheet Functions 8 December 8th 05 08:03 PM
IF Function not working sonicj Excel Discussion (Misc queries) 2 February 2nd 05 02:00 AM
REQ: I need help working out this function. Matthew Webb Excel Programming 1 October 27th 03 12:07 AM


All times are GMT +1. The time now is 02:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"