Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
djd djd is offline
external usenet poster
 
Posts: 11
Default MOD function results

I just need to understand why this is happening.

I have a field where I need to verify that the user entered a value in
increments of 0.5. So I use the formula MOD(field1,0.5). When field1 is
1.5 the result is 0. I have another field where I need to verify that the
user entered a value in increments of 0.2. So my formula is MOD(field2,0.2).
When field2 is 1.2 the result is 0 when the cell is a number but when
defined as general is -1.1102E-16.

I am checking the cells containing the MOD formula in VBA and noticed that
my code for <0 wasn't working even though the cell showed 0. When I used
Watch I saw the exponential.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default MOD function results

Hi,

I'm not sure what you want because you posted this in programming and used
the worksheet syntax for MOD so this is a worksheet answer

format the cell as number to get rid of the -1.1102E-16.

the vba syntax is
x MOD y

Mike

"djd" wrote:

I just need to understand why this is happening.

I have a field where I need to verify that the user entered a value in
increments of 0.5. So I use the formula MOD(field1,0.5). When field1 is
1.5 the result is 0. I have another field where I need to verify that the
user entered a value in increments of 0.2. So my formula is MOD(field2,0.2).
When field2 is 1.2 the result is 0 when the cell is a number but when
defined as general is -1.1102E-16.

I am checking the cells containing the MOD formula in VBA and noticed that
my code for <0 wasn't working even though the cell showed 0. When I used
Watch I saw the exponential.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default MOD function results

The OP must have been talking about the worksheet version of MOD since the
VBA version cannot use non-integer arguments (it will Banker Round any
non-integer arguments before applying the Mod operator). For example...

10.5 Mod 3.5 == 2

because 10.5 Banker Rounds to 10 and 3.5 Banker Rounds to 4 so that the
operation becomes...

10 Mod 4

which is 2 whereas on the worksheet, MOD(10.5,3.5) is 0.

Rick


"Mike H" wrote in message
...
Hi,

I'm not sure what you want because you posted this in programming and used
the worksheet syntax for MOD so this is a worksheet answer

format the cell as number to get rid of the -1.1102E-16.

the vba syntax is
x MOD y

Mike

"djd" wrote:

I just need to understand why this is happening.

I have a field where I need to verify that the user entered a value in
increments of 0.5. So I use the formula MOD(field1,0.5). When field1
is
1.5 the result is 0. I have another field where I need to verify that
the
user entered a value in increments of 0.2. So my formula is
MOD(field2,0.2).
When field2 is 1.2 the result is 0 when the cell is a number but when
defined as general is -1.1102E-16.

I am checking the cells containing the MOD formula in VBA and noticed
that
my code for <0 wasn't working even though the cell showed 0. When I
used
Watch I saw the exponential.


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
MID function results Maria[_4_] Excel Worksheet Functions 4 October 22nd 09 04:25 PM
entering function results into another function excelhurtsme Excel Discussion (Misc queries) 10 December 11th 08 10:10 PM
how do you write format results of a function within a function? sangee Excel Worksheet Functions 3 June 14th 07 12:45 AM
VBA Function results in #NAME? sunfish62 Excel Programming 3 June 24th 05 09:22 PM
Using function results as parameters in another function Steve Haack Excel Worksheet Functions 1 April 24th 05 11:39 PM


All times are GMT +1. The time now is 07:28 AM.

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"