Instant digital downloadExcel and Google SheetsSecure card checkout

Excel and Google Sheets how-to

Stack several columns into one column with TOCOL

Names in three columns, one for each day, and you need them in one list. One formula does it, and the list keeps up when the columns change.

ABCDE
1MonTueWedAll names
2AnaBenCyAna
3DeeEveAnaDee
4FayFay
5GusHalGus
6Ben
7Eve
8Hal
9Cy
10Ana

Sample data: volunteer sign-ups for three days in A2:C5. E2 holds =TOCOL(A2:C5,1,TRUE) and fills E2:E10 by itself.

The formula

Click the top cell of an empty column (E2 here) and type:

=TOCOL(A2:C5,1,TRUE)

E2 to E10 fill with all 9 names: Monday's four first, then Tuesday's three, then Wednesday's two. You type in one cell and the rest fills in by itself, and when a name in A2:C5 changes, the list changes too. If the cells below E2 are not empty, Excel shows #SPILL! instead: clear them and the list appears.

  • A2:C5 is every cell to stack, without the headers.
  • 1 skips the empty cells.
  • TRUE reads one column at a time, top to bottom, so each column stays together.

TOCOL is in Excel for Microsoft 365, Excel for the web, Excel 2024 and Google Sheets. Excel 2021 and older do not have it; the last section has a formula for those.

Column by column or row by row

Leave out TRUE and TOCOL reads across each row instead:

=TOCOL(A2:C5,1)

That gives Ana, Ben, Cy, Dee, Eve, Ana, Fay, Gus, Hal: the first name for each day, then the second, and so on. Reading by row is the default in both Excel and Google Sheets, so add TRUE whenever each column should stay in one piece.

Google Sheets also has FLATTEN, but Google's FLATTEN page says it reads row by row and "Empty values are not skipped", so TOCOL with 1 and TRUE is the easier pick.

Why you get zeros without the 1

Without the 1, every cell in the range comes through, and in Excel the empty ones show as 0. =TOCOL(A2:C5) gives 12 results, three of them 0, instead of 9 names. The second part can be:

  • 0 or left out: keep everything
  • 1: skip blanks
  • 2: skip errors such as #N/A
  • 3: skip blanks and errors

Those four are the same in Excel (Microsoft's TOCOL page) and Google Sheets (Google's TOCOL page).

Leave room for new names

Because the 1 skips empty cells, you can point TOCOL at more rows than you use today:

=TOCOL(A2:C50,1,TRUE)

It gives the same 9 names now and picks up anyone typed into rows 6 to 50 later, with no change to the formula.

One list with no repeats, A to Z

Ana signed up for Monday and Wednesday, so she is in the list twice. UNIQUE takes out repeats and SORT puts the rest in order:

=SORT(UNIQUE(TOCOL(A2:C5,1,TRUE)))

That gives 8 names, Ana to Hal. To count people without listing them, =ROWS(UNIQUE(TOCOL(A2:C5,1,TRUE))) gives 8. To see how many days one person signed up for, =COUNTIF(A2:C5,"Ana") gives 2.

Keep the header beside each value

Often you also need to know which column a value came from, here the day. This puts each name in E and its day in F:

=HSTACK(TOCOL(A2:C5,1,TRUE),TOCOL(IF(A2:C5="",NA(),A1:C1),2,TRUE))

The IF part swaps every name for its column's header (Mon, Tue or Wed) and every empty cell for #N/A, and the 2 skips those #N/A cells, so the days line up with the names: Ana and Mon at the top, Ana and Wed at the bottom. We tested this one for Excel only.

For a table you refresh often, Power Query does the same job with no formula: select the day columns and choose Transform > Unpivot Columns, which turns the columns into rows (Microsoft's Unpivot columns page).

The other way: one column into pairs or columns

Data pasted from a PDF or a web page often lands in one column: a name, then its number, then the next name. WRAPROWS puts every 2 values on their own row:

=WRAPROWS(A1:A6,2)

With North, 120, South, 95, East, 140 in A1:A6 it gives three rows: North 120, South 95, East 140. If the last number is missing, its place shows #N/A; a third part shows something else instead, and =WRAPROWS(A1:A5,2,"") leaves it empty. If blank rows separate the pairs, take them out first:

=WRAPROWS(TOCOL(A1:A9,1),2)

WRAPCOLS fills columns instead, top to bottom. To turn 100 values in A1:A100 into ten columns of 10:

=WRAPCOLS(A1:A100,10)

With the numbers 1 to 100 in A1:A100, the first column shows 1 to 10, the second 11 to 20 and the tenth 91 to 100. With only 95 values, the last column ends in five #N/A cells unless you add the third part. WRAPROWS and WRAPCOLS are in Excel for Microsoft 365, Excel 2024 and Google Sheets.

Make it a fixed list

The list is a live formula. Before you delete or sort the original columns, turn it into plain values: select the list, copy it, then Paste Special > Values in Excel (Edit > Paste special > Values only in Google Sheets). Otherwise the list empties out along with the columns it reads from.

Older Excel without TOCOL

In Excel 2021 or older, type this in E2 and fill it down 12 rows (4 rows times 3 columns):

=INDEX($A$2:$C$5,MOD(ROWS(E$2:E2)-1,4)+1,INT((ROWS(E$2:E2)-1)/4)+1)

The 4 is the number of rows in A2:C5; change it if your data is taller. The formula walks down column A, then B, then C, and shows each empty cell as 0. Add &"" at the end to show those as empty instead (fine for names, but it turns numbers into text), then filter them out.

Free practice sheet

Try it on three everyday jobs: three shift lists into one staff list, a guest list from three sign-up sheets with no repeats, and a pasted list of names and phone numbers put back into pairs. Each tab has yellow cells to fill in and a Check column that says Correct or Try again as you type, plus an Answers tab. One Excel file that opens in Google Sheets too; it needs Excel for Microsoft 365, Excel 2024 or Google Sheets. Free, no sign up. Sample data.

Download the practice sheet (.xlsx)

Templates with the math already done

Rather skip the formulas? These templates come with every formula built and checked, plus a filled-in sample.

Get one tip like this a month

A free email from VARS Digital with one Excel or Google Sheets fix, tested in both apps. No spam, unsubscribe any time.

By signing up you agree that VARS Digital, 10151 240 Street, Maple Ridge, BC V2W 0G9, Canada (inquiries@varsdigital.app) may email you its newsletter: Excel and Google Sheets tips, updates and news about our templates and lessons. We send a confirmation email first, and nothing else goes out until you click it. Every email has an unsubscribe link, and you can leave any time. Details in our store policies.

More how-tos