Forum Discussion
Calculating Two Areas in Excel
- Jan 20, 2022
If you don't see the Developer tab of the ribbon, select File > Options > Customize Ribbon, tick the check box Developer in the list of Main Tabs on the right, and click OK.
Press Alt+F11 to activate the Visual Basic Editor.
Select Insert > Module.
Copy the following code into the worksheet module:
Sub CheckIt() If Application.Sum(Range("D11:D65")) = Application.Sum(Range("D72:D120")) Then MsgBox "Review Completed", vbInformation Else MsgBox "Order quantity does not match delivery quantity, please review!", vbExclamation End If End Sub
Press Alt+F11 to switch back to Excel.
On the Developer tab of the ribbon, in the Controls group, select Insert > Button (Form Control).
Then click on the sheet where you want the button.
Excel will prompt you to select a macro; choose CheckIt, then click OK.
Right-click the button and select Edit Text from the context menu.
Change the caption to Review Order.
Click outside the button when done.
(If you need to move or otherwise modify it later on, right-click on the button)
Save the workbook as a macro-enabled workbook (.xlsm), and make sure that you allow macros when you open it.
Works great!!! One additional question. I'd like to create a button at the top of the form that says "Review Order". Once they populate the form the user will click the "Review Order" button and it will then review the order and delivery section column and either flag it, "Order quantity does not match delivery quantity, please review" or if all is good, display "Review Completed". I'd like the message to be something like a pop-up note/sticky note look.
Can that be done?
If you don't see the Developer tab of the ribbon, select File > Options > Customize Ribbon, tick the check box Developer in the list of Main Tabs on the right, and click OK.
Press Alt+F11 to activate the Visual Basic Editor.
Select Insert > Module.
Copy the following code into the worksheet module:
Sub CheckIt()
If Application.Sum(Range("D11:D65")) = Application.Sum(Range("D72:D120")) Then
MsgBox "Review Completed", vbInformation
Else
MsgBox "Order quantity does not match delivery quantity, please review!", vbExclamation
End If
End Sub
Press Alt+F11 to switch back to Excel.
On the Developer tab of the ribbon, in the Controls group, select Insert > Button (Form Control).
Then click on the sheet where you want the button.
Excel will prompt you to select a macro; choose CheckIt, then click OK.
Right-click the button and select Edit Text from the context menu.
Change the caption to Review Order.
Click outside the button when done.
(If you need to move or otherwise modify it later on, right-click on the button)
Save the workbook as a macro-enabled workbook (.xlsm), and make sure that you allow macros when you open it.
- stephursoJan 21, 2022Copper ContributorAbsolutely amazing! Thank you so much. Your instructions was so easy to follow too. Can't wait for the team to test it out.
Steph