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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
You can use

?INT(val1 / val2)

or

?val1 \ val2

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
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.
 
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
 
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
 
Back
Top