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.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Mon | Tue | Wed | All names | |
| 2 | Ana | Ben | Cy | Ana | |
| 3 | Dee | Eve | Ana | Dee | |
| 4 | Fay | Fay | |||
| 5 | Gus | Hal | Gus | ||
| 6 | Ben | ||||
| 7 | Eve | ||||
| 8 | Hal | ||||
| 9 | Cy | ||||
| 10 | Ana |
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.
- Employee Schedule TemplatePlan your team's shifts week by week with hours, overtime and labour cost.
- Wedding Guest List SpreadsheetEvery guest in one place with RSVPs, meal counts and table seating.
- Attendance TrackerDaily P, A, T and E marks for one class, with rates and absence flags.
More how-tos
- Find a price by its code with XLOOKUPType a product code, get its price back from your price list. One formula, no helper columns.
- Total each category with SUMIFSAdd up all the Fuel, all the Office, all the Meals: one formula per category, and more rules when you need them.
- Check two conditions at once with IF and ANDFree shipping only when the order is 50 or more and ships in Canada: one IF, one AND, done.
- Add leading zeros to numbersType 00021 and Excel or Google Sheets shows 21, because to them it is just the number 21. Here is how to get the zeros back, and keep them.
- Fix #DIV/0! in an averageAn average of nothing is a division by zero, so AVERAGE shows #DIV/0! until the first number arrives. One IF fixes it.
- Count rows that meet two conditions with COUNTIFSHow many of Ana's deals were 500 or more? COUNTIFS answers it in one cell, and takes as many rules as you need.
- Calculate percentage changeSales went from 400 to 500. That is a 25% increase, and one short formula works it out for every row.
- Calculate years of service from a start dateAna started on 15 March 2019. How many full years has she worked? DATEDIF counts them, and the same formula works out an age from a date of birth.
- Combine first and last name into one cellFirst names in one column, last names in the next, and you need "Ana Lopez" in one cell. The & sign joins them.
- Find duplicates in a list with COUNTIFA mailing list where some people signed up twice. One formula shows how many times each email appears, so the repeats stand out.
- Split a full name into first and last nameYour list has "Ana Lopez" in one cell and you need Ana and Lopez in two. Two short formulas find the space and split there.
- Total amounts by month with SUMIFSA list of dated expenses and you want one total per month. SUMIFS adds every amount between the first and the last day of the month.
- Count working days between two datesAna is off from 1 Oct to 14 Oct. How many working days is that? NETWORKDAYS counts Monday to Friday and leaves out the weekends.
- Hide #N/A in VLOOKUP with IFERRORYour order list has a code that is not in the price list, and VLOOKUP shows #N/A. IFERROR puts your own words there instead.
- Count cells that contain textA stock list where some items have a note and most do not. One COUNTIF with an asterisk counts the notes and skips the empty cells.
- Make a running total (cumulative sum)Monthly sales in one column, the total so far in the next. One formula, filled down.
- Round to 2 decimal places, up or downA 15% discount turns 12.99 into 11.0415. ROUND makes it 11.04 and keeps your totals right to the cent. ROUNDUP and ROUNDDOWN handle the times when nearest is the wrong answer.
- How long to $1,000,000? FV and NPERPut $500 a month away at an example 7% a year. FV says what it grows to, NPER says when it passes $1,000,000. Two formulas, no calculator site.
- Why your formula gives the wrong number: the order of operationsA2 holds 10 and A3 holds 4. What does =A2-A3*2 give? It is 2, not 12. The same rule explains most formulas that look right and give the wrong number.
- Why your SUM says 0, and how to fix itThe amounts are right there in the column, and the total says 0. They look like numbers, but the sheet has them stored as text, and SUM skips text.
- Fill handle not working? Copy a formula down fastYou wrote one formula and need it in every row. Here are the quick ways to copy it down, and what to check when the fill handle will not show up or the copies come out wrong.
- Calculate hours worked from start and end timesA shift from 9:00 to 17:30 is 8.5 hours, but subtract the times and the cell shows 8:30. One small change turns it into a number you can add up and multiply by a pay rate.
- IF a cell is blank, or not blankYou want a formula to do one thing when a cell is empty and something else when it is filled. Two double quotes do the job, and they also catch the blanks ISBLANK misses.
- Formulas not updating? Recalculate and refreshYou change a number and the total does not move. It is nearly always one of a handful of things, and each one takes seconds to fix once you know which.
- Standard deviation in Excel and Google SheetsTwo shops both average 40 orders a day. One sells 38 to 42 every day; the other swings from 25 to 55. The average cannot tell them apart. The standard deviation can.
- Long numbers turn into E+ or end in 0 in ExcelYou type a 12 digit order number and Excel shows 5.93774E+11. You type a 16 digit account number and the last digit turns into 0. The first one is only how the cell looks. The second is a real loss, and it has to be stopped before you type.
- Count how many times each value appears in a columnA staff list with a department on every row, and you need to know how many people are in each department. Two short formulas build the count table, and it keeps up when the list changes.
- Free pricing calculatorsPrice a job from your real costs and margin. No sign up.
- Free downloadsPractice sheets and printable pages, no email and no sign up.







