Skip to content

TOCOL

Turns a range or array into a single column, optionally skipping blanks and errors.

Syntax

=TOCOL(, , )

Dynamic arrays

Excel for Microsoft 365, Excel 2024 and later, and Excel for the web. Not available in Excel 2021 or earlier.

Try it

Edit the formula in E2 or change the inputs. The sheet recalculates as you type.

E2
A
B
C
D
E
F
1
Q1
Q2
Q3
2
10
20
30
10
3
40
50
60
20
4
70
80
90
30
5
40
6
50
7
60
8
70
9
80
10
90
11

E2 =TOCOL(A2:C4) returns 10; 20; 30; 40; 50; 60; 70; 80; 90

How TOCOL works

TOCOL flattens a block of cells into one column. A table of 3 rows by 3 columns becomes a list of nine items. It is the tool for reshaping data before you count, rank, filter or chart it.

The arguments

  • array is the block to flatten.
  • ignore controls what to leave out. 0 keeps everything. 1 skips empty cells. 2 skips errors. 3 skips both. Skipping blanks and errors is what makes TOCOL useful on messy ranges.
  • scan_by_column sets the reading order. By default TOCOL reads the first row left to right, then the second row, and so on. With TRUE it reads the first column from top to bottom, then the second column.

=TOCOL(A2:C4) reads 10, 20, 30, 40 and on. =TOCOL(A2:C4,0,TRUE) reads 10, 40, 70, 20 and on. The empty second argument keeps the default.

Cleaning up a range

Real ranges have gaps and the odd error. =TOCOL(A2:C4,3) drops them in one step and returns only the usable values. Without ignore, a blank cell is returned as 0 and an error is returned as the error.

This lets you run other functions on a list that is clean. For example, =SORT(TOCOL(A2:C4,1)) ranks every filled cell in a grid, and =UNIQUE(TOCOL(A2:C4,1)) lists the distinct values it holds.

From a grid to a list

A common job is changing a cross-tab into a list. If a seating plan, a roster or a set of survey answers is spread across a grid, TOCOL puts every item in one column so you can count them with COUNTIF or look something up. Combine it with UNIQUE to find out how many different values the grid contains.

TOCOL, TOROW and the others

TOROW does the same but returns a row. WRAPROWS and WRAPCOLS go the opposite way, folding a single row or column back into a grid. VSTACK joins arrays but keeps their shape. TOCOL is the one that stacks every cell on top of the next.

TOCOL also accepts several ranges at once through VSTACK: =TOCOL(VSTACK(A2:C4,F2:H4)) flattens two separate blocks.

Spilling

The result spills down from the cell you typed in. If the cells below aren't empty, you get #SPILL!. Use # after the anchor cell to refer to the whole list, as in =COUNT(E2#). See FILTER for more.

If nothing is left after the ignore option removes everything, the result is #CALC!.

TOCOL needs Microsoft 365, Excel 2024 or later, or Excel for the web.

Arguments

array
The range or array to flatten, such as A2:C4.
ignoreoptional
0 keeps everything, and is the default. 1 skips blank cells. 2 skips errors. 3 skips both blanks and errors.
scan_by_columnoptional
FALSE, the default, reads the array across each row, left to right, then moves down. TRUE reads down each column, then moves right.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Flatten a grid, row by row

E2 =TOCOL(A2:C4)

Result: 10; 20; 30; 40; 50; 60; 70; 80; 90

TOCOL reads the first row left to right, then the second row, then the third.

E2
A
B
C
D
E
F
1
Q1
Q2
Q3
2
10
20
30
10
3
40
50
60
20
4
70
80
90
30
5
40
6
50
7
60
8
70
9
80
10
90
11

E2 =TOCOL(A2:C4) returns 10; 20; 30; 40; 50; 60; 70; 80; 90

Example 2

Read down the columns instead

E2 =TOCOL(A2:C4,0,TRUE)

Result: 10; 40; 70; 20; 50; 80; 30; 60; 90

The third argument TRUE reads the first column from top to bottom, then the second, then the third.

E2
A
B
C
D
E
F
1
Q1
Q2
Q3
2
10
20
30
10
3
40
50
60
40
4
70
80
90
70
5
20
6
50
7
80
8
30
9
60
10
90
11

E2 =TOCOL(A2:C4,0,TRUE) returns 10; 40; 70; 20; 50; 80; 30; 60; 90

Example 3

Skip the blanks and the error

E2 =TOCOL(A2:C4,3)

Result: 5; 7; 9; 13; 15; 17

B2 is empty and A3 holds #N/A. Option 3 leaves out both, so six clean values remain.

E2
A
B
C
D
E
F
1
Mon
Tue
Wed
2
5
7
5
3
#N/A
9
7
4
13
15
17
9
5
13
6
15
7
17
8
9
10
11

E2 =TOCOL(A2:C4,3) returns 5; 7; 9; 13; 15; 17

Example 4

Skip blanks only: errors stay in the list

E2 =TOCOL(A2:C4,1)

Result: 5; 7; #N/A; 9; 13; 15; 17

Option 1 removes only the empty cell, so the #N/A is returned in its place. Use 2 to remove errors and keep blanks.

E2
A
B
C
D
E
F
1
Mon
Tue
Wed
2
5
7
5
3
#N/A
9
7
4
13
15
17
#N/A
5
9
6
13
7
15
8
17
9
10
11

E2 =TOCOL(A2:C4,1) returns 5; 7; #N/A; 9; 13; 15; 17

Example 5

Sort every value in a grid

E2 =SORT(TOCOL(A2:C4),,-1)

Result: 90; 80; 70; 60; 50; 40; 30; 20; 10

TOCOL turns the grid into a list that SORT can rank. The empty second argument sorts by the first (only) column.

E2
A
B
C
D
E
F
1
Q1
Q2
Q3
2
10
20
30
90
3
40
50
60
80
4
70
80
90
70
5
60
6
50
7
40
8
30
9
20
10
10
11

E2 =SORT(TOCOL(A2:C4),,-1) returns 90; 80; 70; 60; 50; 40; 30; 20; 10

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In E2, list every filled value in A2:C5 in one column, reading across each row. Leave out the empty cells.

Answer in E2.

E2
A
B
C
D
E
F
G
H
I
J
1
Tue
Wed
Thu
2
14
22
3
18
25
30
4
27
5
12
20
6
7
8
9
10
11
12
13

Common mistakes

  • Blank cells come back as 0 unless you set ignore to 1 or 3. A list of scores that includes zeros you did not enter is usually this.
  • The order of the result depends on the third argument. If the order of items matters, decide between row-by-row and column-by-column before you build anything on it.
  • Including the header row in array puts the header text in the list. Start the range at the first data row.
  • #CALC! means the ignore option removed everything, so the result would be empty. Check that the range holds values.
  • The result spills down. #SPILL! means the cells below the formula are not empty.

Questions people ask

How do I convert a table to a single column in Excel?

Use `=TOCOL(A2:C4)`. It reads across each row and returns every cell in one column. Add `,0,TRUE` to read down each column instead.

How do I ignore blank cells with TOCOL?

Set the second argument to 1: `=TOCOL(A2:C4,1)`. Use 3 to skip errors too, and 2 to skip errors only.

How do I combine several columns into one list?

Use `=TOCOL(A2:C20)` for adjacent columns, or `=TOCOL(VSTACK(A2:A20,D2:D20,G2:G20))` for separate ones. Add the ignore option to drop blanks.

What is the difference between TOCOL and VSTACK?

VSTACK stacks arrays and keeps each one's width. TOCOL flattens every cell, so the result is always a single column.

Does TOCOL work in Excel 2019 or 2021?

No. It is available in Microsoft 365, Excel 2024 and later, and Excel for the web. Earlier versions return `#NAME?`.

Learn TOCOL in a real sheet.

Tracks take you from the basics to modelling, one graded exercise at a time.