Sub topic 3
Calculated Columns and Table Tools
Assume you know basic Excel formulas, A1 references, and how to use the Ribbon. This chapter uses an existing table named SalesTable with columns Product, Quantity, Unit Price, and Amount.
Calculated columns
A calculated column is a table column whose formula automatically fills each data row. In the Amount column, enter:
=[@Quantity]*[@[Unit Price]]The @ means “this row.” Excel copies the formula through the column and extends it when you add new records.
Sorting and filtering
Each header contains a filter button. Use it to:
- Sort products from A to Z or by amount.
- Show only rows matching selected values.
- Filter numbers by conditions such as “greater than 100.”
Filtering hides rows; it does not delete them. A calculated column continues to calculate for hidden rows.
Adding a total row
Select any table cell, open the Table Design tab, and select Total Row. Choose Sum for the Amount column. Excel commonly uses this formula:
=SUBTOTAL(109,SalesTable[Amount])SUBTOTAL with function number 109 adds visible values only, so the result changes when you filter the table.
Filtering visually with slicers
A slicer is a clickable filter panel. Select the table, choose Table Design > Insert Slicer, and select fields such as Product. Click a slicer button to filter. Use the clear-filter icon to show all rows again. Slicers are useful in dashboards because the current filter is visible.
Converting back to a range
If table behavior is no longer needed, choose Table Design > Convert to Range. Excel keeps the values and usually keeps the formatting, but removes structured references, automatic expansion, header filter controls, and slicers.
Automating with VBA
Excel stores a table as a ListObject. This macro converts the contiguous data around A1 into a named, styled table with a total row:
Sub CreateSalesTable()
Dim ws As Worksheet
Dim tbl As ListObject
Set ws = ActiveSheet
Set tbl = ws.ListObjects.Add(xlSrcRange, ws.Range("A1").CurrentRegion, , xlYes)
tbl.Name = "SalesTable"
tbl.TableStyle = "TableStyleMedium2"
tbl.ShowTotals = True
End SubExercise
Why might a total row show a smaller sum after filtering?
Show answer
The total row uses SUBTOTAL, which ignores rows hidden by the table's filter.