BYCOL function
Runs a LAMBDA on each column of a range and returns one result per column, for example a total or average for every month.
Available in Microsoft 365, Excel 2024, Excel for the web, Excel for Mac 2024
Excel 2024 and laterWorks in Google Sheets
Syntax
BYCOL(array, lambda(column))| Argument | What it means | |
|---|---|---|
array | Required | The range or array whose columns you want to process. |
lambda | Required | A LAMBDA with exactly one parameter. BYCOL passes each column to it in turn; it must return a single value. |
Returns: A one-row array with one value per column, which spills to the right.
How BYCOL works
BYCOL lets you write one formula that summarises every column of a table. Instead of typing =AVERAGE(B2:B5) under January, copying it under February and March, and fixing it whenever columns are added, you write a single formula and it spills a row of answers — one per column.
You describe what should happen to one column with a LAMBDA, such as LAMBDA(col, AVERAGE(col)). BYCOL hands each column to that LAMBDA as the variable col and collects the results side by side. The LAMBDA must return one value per column; if it returns several values you get #CALC!. Its sister function BYROW does the same across rows.
Examples
1Average monthly sales across stores
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Store | Jan | Feb | Mar |
| 2 | Athens | 1200 | 1350 | 1100 |
| 3 | Berlin | 980 | 1010 | 1250 |
| 4 | Cairo | 1500 | 1420 | 1610 |
| 5 | Dublin | 760 | 890 | 940 |
| 6 | 1110 | 1167.5 | 1225 |
Each month column is passed to AVERAGE. January averages (1200+980+1500+760)/4 = 1110, February 1167.5 and March 1225. The results spill from B6 to D6, right under their months.
2Best store result per month
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Store | Jan | Feb | Mar |
| 2 | Athens | 1200 | 1350 | 1100 |
| 3 | Berlin | 980 | 1010 | 1250 |
| 4 | Cairo | 1500 | 1420 | 1610 |
| 5 | Dublin | 760 | 890 | 940 |
| 6 | ||||
| 7 | 1500 | 1420 | 1610 |
The same pattern with MAX gives the highest figure in each month: 1500, 1420 and 1610 (Cairo every time).
3How many stores reached 1,000 each month
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Store | Jan | Feb | Mar |
| 2 | Athens | 1200 | 1350 | 1100 |
| 3 | Berlin | 980 | 1010 | 1250 |
| 4 | Cairo | 1500 | 1420 | 1610 |
| 5 | Dublin | 760 | 890 | 940 |
| 6 | ||||
| 7 | ||||
| 8 | 2 | 3 | 3 |
COUNTIF counts the values of at least 1,000 in each column: 2 stores in January, 3 in February and 3 in March.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#CALC! | The LAMBDA returns more than one value for a column (for example LAMBDA(c, c*2)). | Make sure the LAMBDA reduces the column to a single value, or use MAP for element-by-element results. |
#VALUE! | The LAMBDA has no parameter or more than one. | Give it exactly one parameter: LAMBDA(col, ...). |
#SPILL! | Cells to the right of the formula are not empty. | Clear the cells the result needs. |
Tips
- In current Microsoft 365 builds you can pass a function name directly:
=BYCOL(B2:D5, SUM)is short forLAMBDA(c, SUM(c)). - Point BYCOL at a whole Excel Table column set (e.g.
Sales[[Jan]:[Mar]]) and the results grow automatically when rows are added.
Google Sheets
BYCOL also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.