ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is there a quotient function in VBA that's like Mod (https://www.excelbanter.com/excel-programming/352079-there-quotient-function-vba-thats-like-mod.html)

WannaBeExceller

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.

Niek Otten

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" wrote in
message ...
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.




Bob Phillips[_6_]

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" wrote in
message ...
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.




WannaBeExceller

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" wrote in
message ...
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.





Tom Ogilvy

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" wrote in
message ...
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.




Tom Ogilvy

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" wrote in message
...
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" wrote in
message ...
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.







All times are GMT +1. The time now is 01:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com