+0  
 
+5
1006
6
avatar+62 

I want to subtract a large number of small number by  Visual Basic or a macro in Excel where the result will be a smaller number.
Example
1000-12 = 4

2000-7=5
This result appears when pressing ENTER or (=) key several times.
Is there a way in excel or a software for this process gives us the result directly without pressing the Enter or (=) key a few times?
many thanks in advance for all.

 Sep 12, 2015

Best Answer 

 #1
avatar+33616 
+20

I think you are referring to the remainder when the larger number is divided by the smaller number.  The function for this is usually called mod.    mod(m,n) gives the remainder when m is divided by n.   So mod(1000,12) = 4 and mod(2000,7) = 5.  This function is in Excel.

 Sep 12, 2015
edited by Alan  Sep 12, 2015
 #1
avatar+33616 
+20
Best Answer

I think you are referring to the remainder when the larger number is divided by the smaller number.  The function for this is usually called mod.    mod(m,n) gives the remainder when m is divided by n.   So mod(1000,12) = 4 and mod(2000,7) = 5.  This function is in Excel.

Alan Sep 12, 2015
edited by Alan  Sep 12, 2015
 #2
avatar+62 
0

many thanks Alan

it's right.

How do I put code in Visual Basic in Excel by this function ( mod )
The first box: any number
The second box: small number (4,7,12)
The third box: result .

FIRST

write any number here
SECOND write 4 or 7 or 12
RESULT  
 Sep 12, 2015
 #3
avatar+33616 
+5

You don't need to write a VBA macro, you can just do something like the following directly in the spreadsheet:

 

 mod function in Excel

In the above you write =MOD(C3,C4) in cell C5

.

 Sep 12, 2015
 #4
avatar+62 
0

thank u very much (Genius*Creative=Alan)

 

 

I have done this way and actually succeeded.

But the problem is if the number is up to 100, so that Excel 2013 sometimes does not accept more than 20 or 14 number in one cell.

Example:
5124536552325647895698745789654789654
(Not possible in Excel to show this number)
-
12
= #NUM (this code sometimes appears when a significant number ).

 

I want the code for Visual Basic in Excel so that you can subtract any number, even up to 1000 number from a smaller number.

 Sep 13, 2015
 #5
avatar+33616 
+10

The function Mod exists in VBA also, though the format is:  m Mod n   rather than MOD(m,n)

 

However, I doubt if VBA will cope with integers that are 1000 digits long (unless you've written special routines to deal with them)!

 Sep 13, 2015
 #6
avatar+62 
0

thank u very much (Genius*Creative*super clever =Alan).

 Sep 13, 2015

2 Online Users