*Resolved* Function to check for Integers?
Is there a worksheet function or formula that can check the result of a calculation to see if the result is an integer and, if so, perform an operation?
I am trying to use an IF...AND formula but only want an action to be carried out if the result of one cell divided by another is an integer. This is the code:
Code:
=IF(AND(E59=TRUE,F58/H18=ISINTEGER),J18,0)
The bit in bold (ISINTEGER) is the part I can't get to work, since there is no ISINTEGER function. But is there something similar which will actually work? I thought there might be functions such as: ISINTEGER, ISINT, ISWHOLENUMBER etc etc, but there appears to be nothing like this.
Anyone got any ideas? :confused:
Re: Function to check for Integers?
Yes Rob, there is the Mod operator.
Mod Operator
Used to divide two numbers and return only the remainder.
Syntax
result = number1 Mod number2
Dim MyResult
MyResult = 10 Mod 5 ' Returns 0.
MyResult = 10 Mod 3 ' Returns 1.
MyResult = 12 Mod 4.3 ' Returns 0.
MyResult = 12.6 Mod 5 ' Returns 3.
HTH
Re: Function to check for Integers?
I don't think that's what he wants, RobDog. Mod always returns an integer, and he wants to see if a division result is an integer. 12/4.3 doesn't return an integer. If both numerator and denominator are known to be integers, Mod will indicate an integer result if the Mod result = 0.
Re: Function to check for Integers?
Hi guys,
No, I think it's okay. I can use the MOD function to check that whether the division results in any remainder, and if it does then infer from this the result I need. I changed the function to read:
Code:
=IF(AND(E59=TRUE,MOD(F58,H18)=0),J18,0)
So the function only returns TRUE if the MOD function returns 0, meaning that the division left no remainder.
Cheers
-Rob