4 of 4: Automating the Spreadsheet using Check Boxes , If Statements, and DSUM
In the previous posts we added Check Boxes to our spreadsheet, linked Check Boxes to cells, and created a conditional summation using DSUM. In this post, we put this altogether with an interactive report. Using Check Boxes, IF statements, and DSUM, the user will select what criteria to sum by.
In the example depicted above, we sum the values in the Amount column based upon the criteria entered in column G.
Watch this ~3m video to learn more.
Adding and Linking the Check Boxes
- Insert two blank rows above the database.
- In the second blank row, add Check Box Form controls for each criteria value to be included in the summary. In the example depicted, we created Check Boxes for each region (see Adding a Check Box for instructions).
- Link the Check Box to the cell above: Right + Click on the Check Box, select Format Control, and enter above cell in the Cell link field (for more detailed instructions click here ). Repeat for each Check Box.
Creating the Criteria Column
We will use the IF function to copy the Checked labels into the criteria range
- In a blank column, enter the field name into the cell (i.e., ‘Region’) .
- Move cursor to the cell immediately below.
- On the Formula tab, in the Function Library group, click Logical and select IF.
- In the Logical_test field, select or type Linked cell above the Check Box. In the example depicted below enter A3 to test Checked state for ‘North America.’
- In the Value_if_true field, select or type the Check Box cell. In the example depicted below enter A4 for the text ‘North America.’
- In the Value_if_false field, type ” – ” (dash in quotes).
- Click OK.
Repeat steps 2 through 7 for each Check Box value to be included in the summation.
To test the IF statements, check and uncheck the boxes. When checked, the text associated with that Check Box will appear in the criteria column.
Inserting the DSUM function
- Select the cell to contain summation (i.e., F5).
- On the Formulas tab, in the Function Library group, click Insert Function. The Insert Function dialog appears.
- In the Search for function area, type DSUM and click Go. DSUM appears in the Selection function area.
- Click OK. The Function Arguments dialog appears.
- In the Database area, enter either the saved name or cell reference for the table (e.g., FoodInventory or A7:F255).
- In the Field area type the column heading to summarize, in quotes (i.e., “Amount”).
- In the Criteria area, type or select the cells that contain the criteria; this includes the column heading(s) and value to search for (i.e., G4:G8).
- Press OK.
Tip: Hide the criteria column to make the report appear less cluttered.
That’s it. Now, to add a region to the summation, check that region’s Check Box. To remove a region from the summation, uncheck it.
Previous post and additional reading:
- Using DSUM
- Adding Check Boxes
- Linking the Check Box to a Cell
- Formatting Indents in Excel
- More Excel Tips
Comments and questions are always welcome!