Sub topic 14
Flash Fill for pattern-based entry
Flash Fill is an Excel feature that watches what you type in a column, detects the pattern that connects it to neighboring columns, and fills the rest of the column to match. This chapter covers how to trigger it, what patterns it recognizes, and where it fails.
This chapter assumes you can enter and commit data in cells, use the fill handle and AutoComplete, and tell the difference between a stored value and a displayed value. Flash Fill builds on all three.
What Flash Fill does
Suppose column A holds full names such as Maria Lopez and you want first names in column B. You could write a formula using LEFT and FIND. With Flash Fill you type one example by hand and let Excel infer the rule.
Flash Fill differs from AutoComplete and the fill handle in what it looks at:
- AutoComplete suggests text based on other entries in the same column.
- The fill handle extends a series or copies values, such as 1, 2, 3 or Monday, Tuesday.
- Flash Fill reads the adjacent columns, compares them to your example, and builds a transformation rule.
The result is static. Flash Fill writes plain values into the cells. It does not write formulas, so the output does not update when the source data changes.
Using Flash Fill step by step
Start with this data in columns A and B, with the headers in row 1.
| A (Full name) | B (First name) |
|---|---|
| Maria Lopez | |
| Chen Wei | |
| Aisha Rahman | |
| Tom O'Neil |
- Click B2 and type
Maria. Press Enter. - In B3, begin typing
Chen. After one or two characters, Excel shows a gray preview of the filled values down the column. - Press Enter to accept the preview. All remaining cells fill at once.
- If no preview appears, press Ctrl+E with the cell below your example selected.
You can also use the Data tab and choose Flash Fill, or use Home > Fill > Flash Fill.
After a fill, a small Flash Fill Options icon appears near the result. Its menu lets you undo the fill, accept the suggestions, or select the cells that were changed. Selecting the changed cells helps when you want to review them.
Patterns Flash Fill recognizes
Flash Fill handles many text-shaping tasks. The table lists common ones.
| Task | Source | Example you type | Result for the next row |
|---|---|---|---|
| Extract first name | `Maria Lopez` | `Maria` | `Chen` |
| Extract last name | `Maria Lopez` | `Lopez` | `Wei` |
| Combine columns | `Maria` and `Lopez` | `Lopez, Maria` | `Wei, Chen` |
| Initials | `Maria Lopez` | `M.L.` | `C.W.` |
| Change case | `maria lopez` | `Maria Lopez` | `Chen Wei` |
| Add a prefix or suffix | `10045` | `ID-10045` | `ID-10046` |
| Extract part of a code | `NY-2024-0381` | `2024` | the middle part of the next code |
| Reformat a phone number | `5551234567` | `(555) 123-4567` | the same layout for the next number |
Flash Fill can also remove characters, such as stripping spaces or hyphens, and can combine parts that sit in different columns.
Where Flash Fill gets it wrong
Flash Fill is a guess based on your examples. It can be wrong in ways that are easy to miss.
Too few examples
One example can match several rules. If you type Maria next to Maria Lopez, Excel may infer "take the first word" or "take the first five characters". With Chen Wei the second rule gives Chen plus part of the next word, which looks wrong. Always scan the whole preview before accepting it. If a row is wrong, press Esc, correct that row by typing the right value, and trigger Flash Fill again. Each added example narrows the possible rules.
Inconsistent source data
Names with middle names, suffixes, or a single word break the "first word" rule in odd ways. For example, Mary Ann Smith and Cher may give unexpected results. Flash Fill does not report errors for these. It simply produces its best guess.
Numbers and dates are treated as text
Flash Fill returns text. If you extract 2024 from a code, the result is stored as text, which left-aligns by default and may not sum or sort numerically. You may see a green triangle indicating a number stored as text. Convert the results with Data > Text to Columns, or multiply by 1 in a helper column, if you need numbers.
Leading zeros are kept, because the output is text. This can be useful, as in the earlier chapter on leading zeros. Flash Fill can reproduce 00123 without you typing an apostrophe in each cell.
Dates behave similarly. A date in the source is a serial number with a date format. Flash Fill reads the displayed text, not the stored value, which is why the pattern follows what you see. If the display format changes later, the Flash Fill output does not change.
Results do not update
Because values are static, editing a source cell leaves the filled cell unchanged. If the source data will change, use a formula instead:
=LEFT(A2,FIND(" ",A2)-1)This formula returns the first word of the text in A2. It updates when A2 changes. Choose Flash Fill for one-time cleanup and formulas for live data.
Blank cells and headers
Flash Fill needs data directly adjacent to the column you are filling. A blank column between the source and the target can stop the pattern from being detected. Headers matter too. Excel uses the header row to understand where the data begins, so give each column a header.
Controlling Flash Fill
Flash Fill is on by default. If it interferes, because previews appear while you type something unrelated, turn it off:
- Choose File > Options > Advanced.
- Under Editing options, clear Automatically Flash Fill.
Ctrl+E still works when automatic Flash Fill is off. Many users prefer this setup, since previews never appear unexpectedly and the shortcut is a deliberate action.
Undo works on a Flash Fill like any other entry. Pressing Ctrl+Z reverses the whole fill in one step, so you can try again with better examples.
Choosing between Flash Fill and other tools
| Situation | Better tool |
|---|---|
| One-time cleanup of a list | Flash Fill |
| Source data will change | Formula such as `LEFT`, `MID`, or `TEXTJOIN` |
| Splitting on a consistent delimiter | Text to Columns |
| Repeating a series or copying a value | Fill handle |
| Replacing a known string everywhere | Find and Replace |
Worked example
You have product codes in column A like SKU-0042-BLU, SKU-0107-RED, and SKU-0009-GRN. You want the number part in column B, keeping its leading zeros.
- In B1, type the header
Number. - In B2, type
0042and press Enter. The value0042may display as42if Excel reads it as a number. To prevent this, type'0042instead. - In B3, start typing
0107. If the preview shows0107and0009in the right rows, press Enter. - If the preview is wrong, press Esc, finish B3 yourself, and select B4. Press Ctrl+E.
- Check the last row. It should show
0009.
Column B now holds text values with their leading zeros. Because they are text, SUM ignores them. If you need arithmetic, keep column A and use VALUE(MID(A2,5,4)) in a formula.
Exercise
Column A contains Lopez, Maria and Wei, Chen. You type Maria Lopez in B2 and use Ctrl+E. Later you change A2 to Lopez, Marie. What happens to B2, and what would you use if you needed B2 to follow A2?
Show answer
B2 stays Maria Lopez, because Flash Fill writes static values, not formulas. To make B2 follow A2, use a formula, for example =TRIM(MID(A2,FIND(",",A2)+1,100))&" "&LEFT(A2,FIND(",",A2)-1), which rebuilds the name whenever A2 changes.
Exercise
Flash Fill shows a preview in which one row is wrong. What are two ways to improve the result?
Show answer
Press Esc, then type the correct value in the wrong row and run Flash Fill again, so Excel has another example to narrow the rule. Alternatively, clean the source data first, for example by removing stray spaces or splitting a messy column, so the pattern is more consistent.