# Need SUMIF/SUMPRODUCT formula with criteria in non-consecutive columns

#### sakinahobbes

##### New Member
Excel masters, I need your help! I'm doing a monthly variance analysis and need a year-to-date formula that will calculate only columns that have monthly actuals populated in them. For example, I have 3 columns for each month (actuals/budget/variance) and a total year-to-date at the end (actuals/budget/variance). I don't want to have to adjust the YTD column formulas at the end of each month close, how can I get a formula that will total my 3 columns (actuals/budget/variance) for only the months that have amounts in the "actuals" column.

For example:
19-Jan 19-Jan 19-Jan 19-Feb 19-Feb 19-Feb 19-Mar 19-Mar 19-Mar YTD YTD YTD
GL code Actuals Budget Variance Actuals Budget Variance Actuals Budget Variance Actuals Budget Variance
1111 1000 1000 1000 ? 3000 ?
2222 2000 2000 2000 ? 6000 ?
3333 3000 3000 3000 ? 9000 ?

If I have actuals for both Jan and Feb (but not March as the month hasn't closed yet), what formula would I put in the YTD actuals/budget/variance columns so that it would only include Jan and Feb but not the march budget (3000). Please tell me I do not need a VBA. Thanks in advance!!!

### Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

#### jim may

##### Well-known Member
Cells in Either Column O or P (O currently used) determine the Number of Months WITH \$\$'s.
Other Formulas in YTD are just nested IF Statements contingent on Column O number.

Excel 2010
ABCDEFGHIJKLMNOP
119-Jan19-Jan19-Jan19-Feb19-Feb19-Feb19-Mar19-Mar19-MarYTDYTDYTD# of PeriodsWith DollarsOr
Alternate
Formula
2GLcodeActualsBudgetVarianceActualsBudgetVarianceActualsBudgetVarianceActualsBudgetVariance
31111100010001000?3000100?4000110022
42222200020002000?6000200?80002200
53333300030003000?9000300?120003300

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
L3=IF(\$O3=1,C3,IF(\$O3=2,SUM(C3,F3),SUM(C3,F3,I3)))
M3=IF(\$O3=1,D3,IF(\$O3=2,SUM(D3,G3),SUM(D3,G3,J3)))
O3=COUNT(\$C3,\$F3,\$I3)
P3=COUNTA(\$C3,\$F3,\$I3)

<tbody>
</tbody>

<tbody>
</tbody>