Excel TOCOL Function: Turn a Grid Into One Column
By ExcelReady TeamUpdated 6 min read
The short answer
TOCOL turns a range or array into a single column. Write =TOCOL(array, [ignore], [scan_by_column]). Use 1 as the second argument to skip blank cells, 2 to skip errors and 3 to skip both. TOCOL reads row by row unless the third argument is TRUE. It needs Microsoft 365 or Excel 2024.
Key takeaways
- =TOCOL(B2:D4) stacks every cell of the grid into one spilled column.
- Without the ignore argument, empty cells come back as 0. Use 1 to skip them.
- TOCOL reads across each row first. Add TRUE as the third argument to read down each column instead.
- =SORT(UNIQUE(TOCOL(B2:D4,1))) gives a clean A to Z list of every name in a grid.
- TOCOL needs Microsoft 365 or Excel 2024. Older versions can use INDEX with INT and MOD.
On this page+
The TOCOL function in Excel turns a grid of cells into one column. You give it a range, such as a rota with names spread across several days, and it stacks every value into a single list. That list is much easier to count, sort or de-duplicate. This guide covers the syntax, the options for blanks and errors, and the formulas people use TOCOL for most.
What does the TOCOL function do?#
TOCOL reads every cell in a range and returns the values in one column. The result is a dynamic array: it spills, which means it fills the cells below the formula automatically. The syntax has three parts:
=TOCOL(array, [ignore], [scan_by_column])| Argument | What it means | Options |
|---|---|---|
| array | The range or array to flatten | Any shape, such as B2:D4 |
| ignore | Values to leave out (optional) | 0 keep all (default), 1 skip blanks, 2 skip errors, 3 skip both |
| scan_by_column | Reading order (optional) | FALSE by row (default), TRUE by column |
TOCOL is available in Microsoft 365, Excel 2024 and Excel for the web. In Excel 2021 or older, the formula shows #NAME?. If spilled results are new to you, read dynamic arrays explained first.
A basic TOCOL example#
The examples below use this shift rota in A1:D4. Cell C3 is empty because nobody is booked for that shift:
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Shift | Mon | Tue | Wed |
| 2 | Early | Ana | Ben | Ana |
| 3 | Late | Cara | Dev | |
| 4 | Night | Eli | Cara | Ben |
Click F2 and type:
=TOCOL(B2:D4)The result spills down nine cells: Ana, Ben, Ana, Cara, 0, Dev, Eli, Cara, Ben. TOCOL reads across row 2, then row 3, then row 4. The 0 is the empty cell C3. TOCOL keeps blanks by default and shows them as zero.
How to skip blanks and errors#
Use the second argument to leave values out. To drop the empty cell:
=TOCOL(B2:D4,1)Now the list has eight names with no 0. The other options work the same way:
- 2 skips error values such as #N/A or #DIV/0!. This is handy when the grid holds lookup results and some lookups fail.
- 3 skips both blanks and errors.
A cell that contains a formula returning "" isn't truly empty, so option 1 keeps it as an empty-looking text value. If your list still has gaps, check the source for formulas like =IF(B2="","",B2).
How to read column by column#
TOCOL reads row by row unless you tell it otherwise. Set the third argument to TRUE to read down each column instead:
=TOCOL(B2:D4,1,TRUE)This returns Ana, Cara, Eli (Monday), Ben, Cara (Tuesday), then Ana, Dev, Ben (Wednesday). Choose the order that matches how the grid is organised. For a rota with days as columns, reading by column keeps each day's names together.
TOCOL has a twin, TOROW, which takes the same arguments and returns one row instead. And if you only want to flip a range sideways while keeping it as a grid, that's a job for TRANSPOSE. The guide to transposing data in Excel explains the difference.
TOCOL with UNIQUE and SORT#
TOCOL is most useful as the first step inside another function. UNIQUE and SORT expect a single list, so TOCOL prepares the grid for them.
To list everyone on the rota once, A to Z:
=SORT(UNIQUE(TOCOL(B2:D4,1)))The result is Ana, Ben, Cara, Dev, Eli. TOCOL flattens the grid, UNIQUE removes the repeats and SORT puts the names in order. The UNIQUE function guide and the SORT function guide explain every argument, and getting unique values from multiple columns shows more variations, including VSTACK for columns that aren't next to each other.
Other useful combinations:
| Goal | Formula | Result on the rota |
|---|---|---|
| Count all booked shifts | =ROWS(TOCOL(B2:D4,1)) | 8 |
| Count different people | =ROWS(UNIQUE(TOCOL(B2:D4,1))) | 5 |
| Shifts for Ana | =SUM(--(TOCOL(B2:D4,1)="Ana")) | 2 |
To use the spilled list in another formula, refer to its first cell with a #. If the TOCOL formula is in F2, =COUNTA(F2#) counts every value it returned. The article on spill range references covers this in detail. The UNIQUE function article has more ways to count and filter the result.
How to flatten a grid in older Excel#
Without TOCOL, use INDEX with INT and MOD to read the grid one position at a time. For a grid 3 columns wide, item number n sits in row INT((n-1)/3)+1 and column MOD(n-1,3)+1. In F2, type:
=INDEX($B$2:$D$4,INT((ROWS($F$2:F2)-1)/3)+1,MOD(ROWS($F$2:F2)-1,3)+1)Fill it down nine rows (Windows: Ctrl+D; Mac: ⌘D). ROWS($F$2:F2) counts 1, 2, 3 as you go down, so each row returns the next item. Change the 3 to the number of columns in your grid. To know how many rows to fill, use =ROWS(B2:D4)*COLUMNS(B2:D4), which gives 9 here. Unlike TOCOL, this method can't skip blanks, and empty cells return 0.
Common TOCOL problems#
Most TOCOL issues come from the version, the space below the formula, or the source data:
- #NAME? Your Excel doesn't have TOCOL. Use the INDEX method above.
- #SPILL! Something is in the way of the result. Clear the cells below the formula.
- Zeros in the list. The source has empty cells. Add 1 as the second argument.
- Wrong order. Switch the third argument between FALSE and TRUE.
- Header text in the list. Start the range below the header row, as in
B2:D4, notB1:D4.
Practise it#
Try the exercise on this page: it uses the INDEX method to find any position in a grid, which is exactly the logic TOCOL runs for you. Then practise modern Excel functions in a live spreadsheet to work with spilled results and # references, and practise UNIQUE in its own lesson to turn long lists into clean ones.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
Older Excel has no TOCOL, but INDEX can still pull the item at any position of the grid, reading row by row. Click F2 and return item number E2 (6) from B2:D4, using INT for the row and MOD for the column, then press Enter.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Position | ||||||
| 2 | |||||||
| 3 | Cara | Dev | |||||
| 4 | Ben | ||||||
| 5 | |||||||
| 6 | |||||||
| 7 |
Tip: The grid is 3 columns wide. INT((E2-1)/3)+1 gives the row and MOD(E2-1,3)+1 gives the column.
Practise this in a lesson
Frequently asked questions
What does TOCOL do in Excel?
TOCOL takes a range or array of any shape and returns all its values in one column. The result spills into the cells below the formula.
How do I stop TOCOL returning zeros?
Zeros appear where the source has empty cells. Add 1 as the second argument, as in =TOCOL(B2:D4,1), and TOCOL skips the blanks.
Why does TOCOL show #NAME? in my Excel?
Your version doesn't have TOCOL. It is available in Microsoft 365, Excel 2024 and Excel for the web, but not in Excel 2021 or older.
What is the difference between TOCOL and TOROW?
They do the same job in different directions. TOCOL returns one column and TOROW returns one row. Both take the same three arguments.
What is the difference between TOCOL and TRANSPOSE?
TRANSPOSE flips a range so rows become columns, but keeps it as a grid. TOCOL flattens the grid into a single column.