Back to articles
Formulas
2025-11-198 min read
#formulas#functions

Sum Each Row or Column in Excel with One Dynamic Formula

Functions in this article

Jump to the reference pages for the Excel functions used below.

Browse library
Table of Contents

Your report has one person per row and one month per column. BYROW can return every person's total from one formula; BYCOL can return every month's total. Each uses LAMBDA to tell Excel which calculation to perform.

For the four-person report below, one formula in F2 produces 300, 280, 150, and 50 down the worksheet. Another in B8 produces 310, 220, and 250 across it. These results spill into neighboring cells, so you don't copy either formula into the rest of its output range.

Use Excel for Microsoft 365 on Windows or Mac, Excel for the web, or Excel 2024 on Windows or Mac. Those are the versions listed in Microsoft's BYROW documentation. If your Excel doesn't recognize the functions, use the copied SUM formulas below.

Set up the monthly report

You can download the example workbook with the original four-person report, copied SUM formulas, and both Table-reference formulas explained below. To build the report yourself, start with the sample data.

On a sheet named Report, paste this tab-separated data into A1:

Person	Jan	Feb	Mar
Ada	120	100	80
Ben	90	80	110
Cara	100		50
Dan	note	40	10
Text

The headers should occupy A1:D1 and the records A2:D5. Leave C4 genuinely empty; the two consecutive tabs in Cara's row leave that space for you. B5 contains the word note. These two cells will help explain how the totals treat missing values and text.

Select A1:D5, choose Insert > Table, and confirm that the table has headers. Name it Reports in the Table Name box on the ribbon. Keep the Total Row off for this example.

Enter Row total in F1 and Copied SUM in H1. Leave F2:F5 empty for the first spill formula, and B8:D8 empty for the column totals. Both output areas are outside the Table.

Compare a copied SUM with one BYROW formula

Start with the familiar approach. In H2, enter:

=SUM(B2:D2)
Formula

Copy H2 down through H5. The reference moves down one row with each copy, giving each person a separate SUM calculation.

Now enter this formula once, in F2:

=BYROW(B2:D5,LAMBDA(values,SUM(values)))
Formula

Press Enter. The expected totals in F2:F5 match the four copied formulas in H2:H5:

PersonRow total in column FCopied SUM in column H
Ada300300
Ben280280
Cara150150
Dan5050

Ada's total is 120 + 100 + 80. Ben's is 90 + 80 + 110. Cara has two numbers and a blank, so her total is 100 + 50. Dan's text entry contributes nothing to SUM, leaving 40 + 10.

The difference is where you maintain the calculation. H2:H5 contains four independent formulas. F2 contains one formula whose results occupy four cells. To change that calculation, edit F2, rather than one of its spilled results below it.

Follow one row through LAMBDA

Read the F2 formula from the outside in. B2:D5 is the block BYROW divides into rows. On its first pass, it supplies B2:D2 to LAMBDA.

The name values stands for that row's three cells. SUM(values) adds them and returns 300. BYROW then supplies B3:D3 to the same calculation, followed by B4:D4 and B5:D5. Four input rows produce four results in a single column.

You don't need to define values in Name Manager. It is a parameter used inside this LAMBDA, and BYROW supplies its input. Saving a calculation for use elsewhere is a separate step, covered in creating a custom Excel function with LAMBDA.

Use BYCOL for monthly totals

In B8, enter:

=BYCOL(B2:D5,LAMBDA(values,SUM(values)))
Formula

Only the outer function has changed to BYCOL. This time, the calculation receives B2:B5 first, then C2:C5, then D2:D5. The expected results spill horizontally:

B8: JanC8: FebD8: Mar
310220250

January adds 120 + 90 + 100, ignoring Dan's text entry. February adds 100 + 80 + 40, ignoring Cara's blank. March adds all four numbers: 80 + 110 + 50 + 10.

Microsoft's BYCOL documentation describes this output shape: each input column produces one result, arranged across a single output row.

These SUM calculations include all referenced records, even when you filter the Table. If you need a column summary that changes with the visible records, use the Table Total Row and its filter-aware formulas.

Include new records with Table references

There is one catch with both formulas so far: B2:D5 stops at row 5. Adding another person to Reports doesn't extend that fixed reference.

Replace the formula in F2 with:

=BYROW(Reports[[Jan]:[Mar]],LAMBDA(values,SUM(values)))
Formula

BYROW formula in F2 with four row totals and a visible spill outline.
Using the Table reference, BYROW spills one total for each input row: 300, 280, 150 and 50.

Then replace the formula in B8 with:

=BYCOL(Reports[[Jan]:[Mar]],LAMBDA(values,SUM(values)))
Formula

BYCOL formula selected in B8 with three monthly totals 310, 220 and 250.
Using the same Table reference, BYCOL spills one total for each month: 310, 220 and 250.

Reports[[Jan]:[Mar]] means the Table's data columns from Jan through Mar. It leaves out Person and the header row. Unlike the fixed cell range, it expands when the Table gains a data row. The structured reference walkthrough explains how those table and column names fit together.

Keep both formulas outside Reports: a Table can supply the input, but the spill output needs ordinary worksheet cells.

To check the expanding references, add Eva, 20, 30, and 40 in A6:D6. Make sure the Table includes the new row, and keep F6 empty. You should now see 90 as the fifth row total in F6, and these column totals:

JanFebMar
330250290

The versions using B2:D5 would still show only the original four row totals and column totals of 310, 220, and 250. Likewise, the copied SUM comparison needs another formula in H6 if you want it to include Eva.

Keep space between the Table and the totals below it. B8 works for this small example, but a growing report will eventually reach row 8; move the column-total formula farther down or to a separate sheet before that happens. To restore the original example without shifting the totals, clear A6:D6 and resize Reports back to A1:D5. Clearing Eva's values alone leaves an extra blank Table row and a fifth row total of 0.

Check blank cells, text, and source errors

SUM ignores blank cells and text in the referenced inputs. Replacing Cara's blank C4 with text therefore leaves her row total at 150. A row whose three month cells are all blank returns 0, so BYROW still gives that row a result.

That behavior can also conceal a data-entry problem. If an amount is stored as text, it may be left out of the total. Check the source cells when a result seems too low; formatting a cell to look like a number doesn't guarantee its underlying value is numeric.

An error value is different from text. If a numeric source cell contains #N/A, its row total and its column total also return an error. For example, a source error in B2 affects Ada's result in F2 and January's result in B8. Fix the source error instead of assuming SUM will skip it.

Fix a blocked spill or an invalid calculation

#SPILL! means the output needs space. If F3 already contains text when you enter the formula in F2, Excel cannot place all four row totals. Clear or move the obstruction in F2:F5. For the column formula, check B8:D8. Also check for merged cells and make sure the formula itself is outside the Table. The Excel formula error guide covers these checks in more detail.

#VALUE! can mean the LAMBDA has the wrong number of parameters. BYROW and BYCOL each supply one input at a time: a whole row or a whole column. The examples declare one parameter, values, followed by the calculation.

#CALC! can mean the calculation returns too many values. Each row or column must be reduced to one result. SUM(values) does that; returning the row or column unchanged does not. These parameter and result requirements are documented in Microsoft's BYCOL error guidance.

If Excel doesn't recognize BYROW or BYCOL, check your version before changing the calculation. The copied formula in H2:H5 remains an option in older Excel versions. For monthly totals, enter this formula in B8 and copy it across through D8:

=SUM(B2:B5)
Formula

Enjoyed this guide?

Join our newsletter to get the latest Excel tips delivered to your inbox.

You can unsubscribe anytime. See our Privacy Policy.