Sort, Filter and Excel Tables
Sort and filter without scrambling rows, total only visible data, convert ranges into Excel Tables, and stop bad entries with data validation.
Welcome back!
Step 1 of 14Learn
Sorting without scrambling your data
Dev wants his customer list in alphabetical order. He selects column A, the names, and clicks Sort A to Z. The names are sorted beautifully, but the phone numbers and balances in columns B and C stayed where they were. Every customer now has someone else's balance. It's one of the most damaging spreadsheet mistakes, and it happens in seconds.
The safe way: click any single cell inside the data (not a whole column), then use Data > Sort. Excel detects the whole block and the header row, and keeps every row together. If Excel ever shows a "Sort Warning" offering to expand the selection, choose Expand.
The Sort dialog also allows multi-level sorts. Sort a sales list by Region (A to Z), then by Amount (largest to smallest) within each region, and you see each region's biggest deals at the top. Levels are applied in priority order: the first level is the main grouping, the second breaks ties.
Other useful options: sort by cell color, sort left to right instead of top to bottom, and custom lists so months sort January, February, March instead of alphabetically (April, August, December).
Before any major sort, a quick safety net helps: add an "ID" column numbered 1, 2, 3 … You can always re-sort by ID to get the original order back.
Step 2 of 14Compare
Dev's sort vs a safe sort
| Aspect | Select one column, then sort | Click one cell, then sort |
|---|---|---|
| What Excel sorts | Only the selected column | The whole connected list |
| Rows | Torn apart: names no longer match balances | Kept together |
| Warning | Excel may offer to expand the selection; choosing "continue" breaks the data | None needed |
| Fix if it happens | Ctrl+Z immediately | Nothing to fix |
Step 3 of 14Practice · What would you do?
What would you do?
Ana selects only column C (Sales) in a list of names, regions and sales, and clicks Sort Largest to Smallest. Excel shows a Sort Warning with two options. What should she choose, and why?
Step 4 of 14Learn
Filters: see only the rows you need
A filter temporarily hides rows that don't meet your conditions, without deleting anything. Click inside your data and press Ctrl+Shift+L (or Data > Filter). Drop-down arrows appear in each header.
From the arrows you can:
- Tick or untick values: show only the West and North regions.
- Use Number Filters: greater than 1,000, between two values, top 10, above average.
- Use Text Filters: contains "refund", begins with "INV".
- Use Date Filters: this month, last quarter, a custom date range.
- Filter by color, if rows are highlighted.
Filters on several columns combine like AND: Region = West and Amount > 1,000. Row numbers turn blue to remind you that some rows are hidden, and the status bar shows how many records are visible.
Here's the catch: SUM, AVERAGE and COUNT still include hidden rows. If you filter to West and look at a =SUM total below the data, you see the grand total, not the West total. To calculate only visible rows, use SUBTOTAL or AGGREGATE: =SUBTOTAL(109, D2:D500) sums only the visible cells (9 means sum; adding 100 also ignores rows hidden by hand). AutoSum on a filtered list writes a SUBTOTAL formula for you.
To remove all filters at once, press Ctrl+Shift+L again or click Clear on the Data tab.
Step 5 of 14Practice · True or false
When a list is filtered to show only the West region, =SUM(D2:D500) below the list adds only the visible West amounts.
Step 6 of 14Practice · Chart
A list filtered to West: two totals
Which formula reports only the visible West rows?
Tap the bar that answers the question, then press Check.
Step 7 of 14Learn
Excel Tables: ranges that look after themselves
Select any cell in a clean list and press Ctrl+T (Insert > Table). Confirm that the list has headers, and the plain range becomes an Excel Table. That small step gives you a lot:
- It grows automatically. Type a new row directly under the table and it joins the table. Formulas, charts and PivotTables built on the table include it without editing any ranges.
- Calculated columns. Type a formula once in a new column and it fills the entire column instantly, and stays consistent as rows are added.
- Structured references. Formulas use names instead of addresses:
=SUM(Sales[Amount])instead of=SUM(D2:D2001). Inside the table, a row's own value appears as [@Amount], so =[@Qty]*[@Price] reads like plain English. - Built-in filter buttons, banded rows and a Total Row (Table Design tab) that offers Sum, Average, Count and more from a drop-down, using SUBTOTAL so filtered views total correctly.
Give the table a meaningful name on the Table Design tab, such as Sales or Products, instead of Table1. Lookups then read clearly: =XLOOKUP(B2, Products[ID], Products[Price]).
Tables expect a proper list: one header row with unique names and no merged cells. That's another reason the clean-data habits from Module 1 pay off.
Step 8 of 14Diagram
What Ctrl+T gives you
Tap a shape with to see more.
- Excel Table
- Grows automatically
New rows typed below join the table, and everything built on it includes them.
- Calculated columns
One formula fills the whole column.
- Structured references
=SUM(Orders[Amount]) instead of cell ranges.
- Filter buttons and banding
- Optional total row
Uses SUBTOTAL, so it respects filters.
Step 9 of 14Practice · Select all that apply
Which of these are real benefits of converting a range into an Excel Table? Select all that apply.
Select all that apply.
Step 10 of 14Learn
Clean data, and keep it clean
Most data you receive is messy: duplicate rows, extra spaces, numbers stored as text, names in one column that should be in two. A few built-in tools fix most of it:
- Remove Duplicates (Data tab): choose which columns define a duplicate. Ticking only Email removes repeat customers; ticking every column removes only rows identical in every field. Work on a copy first; removal is permanent once you save.
- Text to Columns (Data tab): split "Smith, John" into two columns at the comma. It also converts numbers stored as text into real numbers if you simply run it and click Finish.
- Find and Replace (Ctrl+H): change "N.Y." to "NY" everywhere, or replace double spaces with single ones.
- TRIM and other text functions, covered in the next lesson, for cleanup that needs a formula.
Better still, prevent bad data at the point of entry with Data Validation (Data > Data Validation). You can restrict a cell to a drop-down list of allowed values, whole numbers in a range, dates after a certain day, or text of a maximum length, and show a friendly input message or error alert.
A drop-down list of regions, for example, makes "Wset", "west " and "W." impossible, so COUNTIFS and PivotTables count correctly forever. Ten minutes of validation saves hours of cleanup.
Step 11 of 14Flashcards
Cleaning tools: which one for which mess?
Tap a card to flip it.
Step 12 of 14Practice · Put in order
Put the steps for adding a drop-down list of allowed regions to a column in order.
Drag the items, or use the arrow buttons, to put them in order.
- Set Allow to "List" and point Source to the list of regions
- Type the allowed regions in a list, such as on a Lists sheet
- Select the cells where people will enter a region
- Click OK and test the drop-down arrow in a cell
- Open Data > Data Validation
Step 13 of 14Note
Step 14 of 14Practice · Choose one
A table named Orders has columns Date, Region and Amount. What does =AVERAGE(Orders[Amount]) calculate?
Lesson complete!