The division is one of the most basic and frequent arithmetic operations in our daily life. At times, we need only the integer part from a division result which means division result without remainder. In this article, I will show you how to divide without remainder in Excel by using VBA.
How to Divide Without Remainder by Using Excel VBA: 2 Easy Ways
Assuming that we have a data set of 5 dividends in cells B5:B9 and 5 divisors in cells C5:C9. Now, we need to perform the division process and get 5 quotients in cells D5:D9 as integers without remainders.
We want to accomplish this with Excel VBA. Follow any of the two ways given below to achieve this.
1. Division Using Backslash (\) Operator
We can divide numbers through Excel VBA by using the backslash (\) symbol to get the result as integers. Follow the steps below to do this.
📌 Steps:
- First and foremost, go to the Developer tab >> Visual Basic tool.
- As a result, the VB Editor window will appear.
- Following, go to the Insert tab >> Module option.
- Consequently, a new module named Module1 will be created.
- Now, double-click on Module1 and insert the following VBA code in the code window.
Sub Backward_Slash_Division()
Range("D5") = Range("B5") \ Range("C5")
Range("D6") = Range("B6") \ Range("C6")
Range("D7") = Range("B7") \ Range("C7")
Range("D8") = Range("B8") \ Range("C8")
Range("D9") = Range("B9") \ Range("C9")
End Sub
- Subsequently, press Ctrl + S on your keyboard.
- As a result, a Microsoft Excel dialogue box would appear. Click on the No button.
- Consequently, the Save As dialogue box would appear.
- Following, choose the Save as type: option as .xlsm file and click on the Save button.
- At this time, close the code window and go to the Developer tab >> Macros tool.
- As a result, the Macro window would appear.
- Following, click on the Backward_Slash_Division macro and click on the Run button.
Thus, the VBA code will run and give you the quotient without remainders for the divisions. And, the result should look like this.
- If you need your result somewhere else, declare that cell range inside the left side’s Range function. And, if the dividend and divisor are in different cells apart from the used range in the example, declare those cell ranges in the right side’s Range function as your own requirements.
- If you use forward slash (/) instead of backslash (\) here, you will not get the integer quotient. Rather, you would get the actual quotient with decimals.
2. Using VBA Quotient Function to Divide One Cell by Another Without Remainder
Besides, you can use the Quotient function of VBAÂ to divide cells and get results without remainders. Follow the steps below to accomplish the result of this process.
📌 Steps:
- Similar to the first way, insert a module named Module2 in your Excel workbook.
- Following, insert the following VBA code in the Module2 code window and press Ctrl + S.
Sub Division_Quotient_Function()
Range("D5") = WorksheetFunction.Quotient(Arg1:=Range("B5"), Arg2:=Range("C5"))
Range("D6") = WorksheetFunction.Quotient(Arg1:=Range("B6"), Arg2:=Range("C6"))
Range("D7") = WorksheetFunction.Quotient(Arg1:=Range("B7"), Arg2:=Range("C7"))
Range("D8") = WorksheetFunction.Quotient(Arg1:=Range("B8"), Arg2:=Range("C8"))
Range("D9") = WorksheetFunction.Quotient(Arg1:=Range("B9"), Arg2:=Range("C9"))
End Sub
- Afterward, save the Excel file in .xlsm format following the previous way.
- Afterward, similar to the previous way, go to the Developer tab and click on the Macros tool to open the Macro window.
- Following, choose the Division_Quotient_Function macro and click on the Run button.
Thus, you will get your desired result as integers without any remainder and the final result should look like this.
If you need your result somewhere else, declare that cell range inside the left side’s Range function. And, if the dividend and divisor are in different cells apart from the used range in the example, declare those cell ranges in the Arg: argument as your own requirements.
Download Practice Workbook
You can download our practice workbook from here for free!
Conclusion
So, in this article, I have shown you two easy ways to divide without any remainder in Excel VBA. You can also download our free workbook to practice. I hope you find this article helpful and informative. If you have any further queries or recommendations, please feel free to comment here.