+ Reply to Thread
Results 1 to 6 of 6

Is there a quotient function in VBA that's like Mod

  1. #1
    WannaBeExceller
    Guest

    Is there a quotient function in VBA that's like Mod

    I am trying to do a division but only want the quotient part. I thought there
    would be a DIV function that works like MOD function. Thanks in advance.

  2. #2
    Niek Otten
    Guest

    Re: Is there a quotient function in VBA that's like Mod

    =FLOOR(A1/B1,SIGN(A1)*1)

    Or, if you only have positive numbers,

    =INT(A1/B1)


    --
    Kind regards,

    Niek Otten

    "WannaBeExceller" <[email protected]> wrote in
    message news:[email protected]...
    >I am trying to do a division but only want the quotient part. I thought
    >there
    > would be a DIV function that works like MOD function. Thanks in advance.




  3. #3
    WannaBeExceller
    Guest

    Re: Is there a quotient function in VBA that's like Mod

    Thank you for your response. I found that to work as well as just using the
    "\" sign in the division instead of using "/". Thank you once again.

    "Niek Otten" wrote:

    > =FLOOR(A1/B1,SIGN(A1)*1)
    >
    > Or, if you only have positive numbers,
    >
    > =INT(A1/B1)
    >
    >
    > --
    > Kind regards,
    >
    > Niek Otten
    >
    > "WannaBeExceller" <[email protected]> wrote in
    > message news:[email protected]...
    > >I am trying to do a division but only want the quotient part. I thought
    > >there
    > > would be a DIV function that works like MOD function. Thanks in advance.

    >
    >
    >


  4. #4
    Bob Phillips
    Guest

    Re: Is there a quotient function in VBA that's like Mod

    You can use

    ?INT(val1 / val2)

    or

    ?val1 \ val2

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "WannaBeExceller" <[email protected]> wrote in
    message news:[email protected]...
    > I am trying to do a division but only want the quotient part. I thought

    there
    > would be a DIV function that works like MOD function. Thanks in advance.




  5. #5
    Tom Ogilvy
    Guest

    Re: Is there a quotient function in VBA that's like Mod

    Dividend ÷ Divisor = Quotient

    If you really mean the quotient, then

    for a worksheet formula

    =6/3

    would return 3

    in VBA

    res = 6/3
    res would contain 2

    dim res as double
    res = 5/3
    res would contain 1.66666666666667 or there abouts.

    from the immediate window:
    res#=5/3
    ? res
    1.66666666666667

    --
    Regards,
    Tom Ogilvy

    "WannaBeExceller" <[email protected]> wrote in
    message news:[email protected]...
    > I am trying to do a division but only want the quotient part. I thought

    there
    > would be a DIV function that works like MOD function. Thanks in advance.




  6. #6
    Tom Ogilvy
    Guest

    Re: Is there a quotient function in VBA that's like Mod

    Just to ADD:

    http://mathworld.wolfram.com/Quotient.html

    My answer interpreted Quotient with the most common interpretation. If you
    want the whole number portion of a division

    i.e, If you want the Integer portion of the Quotient <g>, then look in Excel
    VBA help at TRUNC and INT

    in VBA, use integer division ( \ )

    ? 6\4
    1
    ? -6\4
    -1

    --
    Regards,
    Tom Ogilvy

    "Tom Ogilvy" <[email protected]> wrote in message
    news:[email protected]...
    > Dividend ÷ Divisor = Quotient
    >
    > If you really mean the quotient, then
    >
    > for a worksheet formula
    >
    > =6/3
    >
    > would return 3
    >
    > in VBA
    >
    > res = 6/3
    > res would contain 2
    >
    > dim res as double
    > res = 5/3
    > res would contain 1.66666666666667 or there abouts.
    >
    > from the immediate window:
    > res#=5/3
    > ? res
    > 1.66666666666667
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "WannaBeExceller" <[email protected]> wrote in
    > message news:[email protected]...
    > > I am trying to do a division but only want the quotient part. I thought

    > there
    > > would be a DIV function that works like MOD function. Thanks in advance.

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1