Results 1 to 4 of 4

Thread: *Resolved* Function to check for Integers?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    Resolved *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?
    Last edited by TheRobster; Dec 17th, 2004 at 09:06 AM. Reason: Resolved

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    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.
    Tengo mas preguntas que contestas

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width