TOCOL function
Turns a range or array into a single column, reading row by row (or column by column), with options to skip blanks and errors.
Available in Microsoft 365, Excel 2024, Excel for the web, Excel for Mac 2024+
Excel 2024 and laterWorks in Google Sheets
Syntax
TOCOL(array, [ignore], [scan_by_column])| Argument | What it means | |
|---|---|---|
array | Required | The range or array to flatten. |
ignore | Optional | 0 keep everything (default), 1 skip blanks, 2 skip errors, 3 skip blanks and errors. |
scan_by_column | Optional | FALSE (default) reads across each row first; TRUE reads down each column first. |
Returns: A single-column array containing every value of array, which spills.
How TOCOL works
TOCOL takes a block of cells and lines all the values up in one column. Think of a weekly shift roster where names are spread across a grid: TOCOL lists every name in one column, ready for UNIQUE, COUNTIF or SORT.
By default it reads the first row left to right, then the second row, and so on; set scan_by_column to TRUE to read column by column instead. Blank cells become 0 unless you ask to ignore them with ignore set to 1, which you almost always want. Errors can be skipped too, which makes TOCOL a neat way to clean up a messy range.
Examples
1Flatten a roster
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Mon | Tue | Wed | Ana | |
| 2 | Ana | Ben | Ana | Ben | |
| 3 | Raj | Chloe | Ana | ||
| 4 | Raj | ||||
| 5 | 0 | ||||
| 6 | Chloe |
Read row by row. The empty Tuesday slot becomes 0 because blanks are not ignored.
2Skip blanks, read by column
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Mon | Tue | Wed | Ana | |
| 2 | Ana | Ben | Ana | Raj | |
| 3 | Raj | Chloe | Ben | ||
| 4 | Ana | ||||
| 5 | Chloe |
ignore 1 drops the blank cell; scanning by column reads Monday's names first, then Tuesday's, then Wednesday's.
3Distinct staff on the roster
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Mon | Tue | Wed | Ana | |
| 2 | Ana | Ben | Ana | Ben | |
| 3 | Raj | Chloe | Chloe | ||
| 4 | Raj |
TOCOL lines up the names, UNIQUE removes the repeated Ana and SORT orders them.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#SPILL! | Not enough room below the formula. | Clear the cells underneath. |
#NUM! | The result would have more rows than the sheet allows. | Flatten a smaller range. |
Tips
- Use
ignore3 to clean a range of both blanks and error values. - TOROW does the same in a single row; WRAPROWS does the reverse, turning a list back into a grid.
Google Sheets
TOCOL also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
TOCOL in other languages
In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.
Recipes that use TOCOL
- How to find the last value in a column in Excel
- How to transpose rows and columns in Excel
- How to unpivot data in Excel with Power Query