Cellwise Start free

Excel guide · 4 min read

How to SUMIF across multiple columns in Excel

Quick answerSUMIF can only add one column, so =SUMIF(A2:A9,"North",B2:G9) quietly sums January alone. To add every month for North, multiply the condition by the whole block: =SUMPRODUCT((A2:A9="North")*B2:G9). Or add a Total column with =SUM(B2:G2) per row and SUMIF that one column.

Sample data

Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.

ABCDEFGHIJ
1RegionJanFebMarAprMayJunTotalNorth
2North42003900465051004800530027950Mar
3South310029503400360035503900205003
4North28003050290032003350340018700
5East54005100580061005900640034700
6South26002700250029003100300016800
7North19002100225024002600250013750
8East33003500345037003650390021500
9West00120026003100380010700

Download this sheet as an Excel practice file (.xlsx)

Why SUMIF only adds the first column

The sheet has sales by region for January to June, with North appearing on three rows. The obvious formula gives the sum range as the whole block B2:G9, and Excel accepts it without complaint.

But SUMIF sizes the sum range to match the criteria range. A2:A9 is one column wide, so Excel uses only B2:B9, the January column, and ignores February to June. The result looks plausible, which is why this goes unnoticed: 8,900 is a real number, it is just North's January sales. SUMIFS is no help either, as all of its ranges must be the same size.

=SUMIF(A2:A9,"North",B2:G9)

Result: 8900

8,900, exactly what =SUMIF(A2:A9,"North",B2:B9) returns. The other five months are left out.

Method 1: SUMPRODUCT across the whole block

SUMPRODUCT can work on a block. (A2:A9="North") makes a column of TRUE and FALSE, and multiplying it by B2:G9 turns every non-North row into zeros while keeping the North rows. SUMPRODUCT then adds everything that is left: all six months for the three North rows.

Use the multiplication form shown here. The comma form =SUMPRODUCT(--(A2:A9="North"),B2:G9) returns #VALUE!, because with commas every array must be the same shape, and a one-column test does not match a six-column block.

It works in every version of Excel and needs no Ctrl+Shift+Enter. The ranges must have the same number of rows: A2:A9 with B2:G10 is an error.

=SUMPRODUCT((A2:A9="North")*B2:G9)

Result: 60400

60,400, the total for North across all six months. The whole block for every region adds to 164,600.

Method 2: a Total column, then a normal SUMIF

If you control the layout, add a Total column at the end of each row with =SUM(B2:G2) and fill it down (column H in the sample). Now there is one column to add, and an ordinary SUMIF does the job.

This is the easiest version to read and audit, and it handles text in the data well. SUM inside each row skips a stray "n/a" or a dash, while SUMPRODUCT multiplies the text and returns #VALUE! for the whole formula. With "n/a" typed in North's March cell, the SUMPRODUCT above breaks, and =SUM(FILTER(B2:G9,A2:A9="North")) still works in Excel 365 and 2021, returning 55,750 because SUM skips the text.

In Excel 365 you can also list every region with its total in one go with =LET(r,UNIQUE(A2:A9),HSTACK(r,SUMIF(A2:A9,r,H2:H9))): North 60,400, South 37,300, East 56,200, West 10,700.

=SUMIF(A2:A9,"North",H2:H9)

Result: 60400

60,400, the same total as SUMPRODUCT, from a single column.

Method 3: pick the month by its header

Often you want one month, chosen in a cell: J1 holds the region and J2 the month. INDEX with 0 as the row number returns the whole column whose position XMATCH finds in the header row, and because INDEX returns a real range, SUMIFS accepts it. Change J2 to Jun and the formula moves to column G. XMATCH needs Excel 365 or 2021; in older versions use MATCH(J2,B1:G1,0).

A tempting alternative is CHOOSECOLS, but SUMIFS only takes ranges and CHOOSECOLS returns an array, so Excel will not accept SUMIFS(CHOOSECOLS(...),...). Use CHOOSECOLS inside SUMPRODUCT instead: =SUMPRODUCT((A2:A9=J1)*CHOOSECOLS(B2:G9,XMATCH(J2,B1:G1))) gives the same 9,800.

For a two-way condition without INDEX, compare the header row as well: =SUMPRODUCT((A2:A9=J1)*(B1:G1=J2)*B2:G9). The column test runs across and the row test runs down, so only the cells where both are true are added.

=SUMIFS(INDEX(B2:G9,0,XMATCH(J2,B1:G1)),A2:A9,J1)

Result: 9800

9,800, North's March sales (4,650 + 2,900 + 2,250).

Year to date: the first N months

For a running total up to a month, add a test on the column position. J3 holds 3 for "January to March". The months must be in order from left to right for this to mean year to date.

Writing it out by hand works too, as =SUMIFS(B2:B9,A2:A9,J1)+SUMIFS(C2:C9,A2:A9,J1)+SUMIFS(D2:D9,A2:A9,J1), but every new month means editing the formula. The position test updates when you change J3.

=SUMPRODUCT((A2:A9=J1)*(COLUMN(B1:G1)-COLUMN(B1)+1<=J3)*B2:G9)

Result: 27750

27,750, North's sales for January to March. The three added SUMIFS give the same number.

Which method to pick

Use a Total column and SUMIF when you can change the sheet: it is fast, readable and tolerant of text. Use SUMPRODUCT when the layout is fixed, such as a report someone else sends you, and the block holds only numbers and blanks. Use INDEX/XMATCH inside SUMIFS when the month comes from a drop-down, and the position test for year to date.

If the data has many rows and you need it every month, consider reshaping it into a long table (Region, Month, Sales). Then every question is a plain SUMIFS or a PivotTable, and a new month is new rows rather than a new column.

Common mistakes

Giving SUMIF a multi-column sum range

It only adds the first column, with no warning. Use SUMPRODUCT on the block or SUMIF a Total column.

Using the comma form of SUMPRODUCT

=SUMPRODUCT(--(A2:A9="North"),B2:G9) is #VALUE! because the shapes differ. Multiply instead: (A2:A9="North")*B2:G9.

Text such as n/a or a dash in the numbers

SUMPRODUCT returns #VALUE!. Clear the text, sum a Total column, or use SUM(FILTER(...)), which skips text.

Ranges with different row counts

A2:A9 must line up with B2:G9 row for row. Check both start and end on the same rows.

FAQ

Can SUMIF sum multiple columns?

No. SUMIF adds a single column; a wider sum range is cut down to the size of the criteria range, so only its first column counts. Use =SUMPRODUCT((A2:A9="North")*B2:G9) instead.

How do I sum multiple columns based on one criterion?

Multiply the condition by the block of columns in SUMPRODUCT, or add a Total column per row and use a normal SUMIF on it.

How do I sum a column chosen by its header?

Use INDEX with 0 rows and XMATCH on the headers as the sum range: =SUMIFS(INDEX(B2:G9,0,XMATCH(J2,B1:G1)),A2:A9,J1).

Why does SUMPRODUCT return #VALUE!?

Usually text in the number block, ranges with different row counts, or the comma form with arrays of different shapes. Multiply the condition by the block and clean any text.

Functions used

Related guides

Updated