Sum cell in every nth column only if adjacent cell is not blank

Karlab

New Member
Joined
Jan 19, 2012
Messages
10
I am using the following formula to add my actual spending at every 2nd column for my YTD actual spending:
=SUMPRODUCT((MOD(COLUMN($B2:$E2),2)=0)*($B2:$E2))

In the YTD Budget column, I want to add the Budget-Jan and Budget-Feb cells ONLY if the Actual cell for that month (cell to left) is not blank. (So result for YTD Budget in top cell would be 4.) Can anyone help me with a formula for this? FYI, I don't want to convert my spreadsheet to a Table. Thank you!
CategoryActual-JanBudget-JanActual-FebBudget-FebYTD ActualYTD Budget
Bonus2442
Interest Inc4444
Other Inc6446
Net Salary Dave2442
Net Salary Karla2442
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You could use offset function or with the way yours is setup you can actually feed the formula an offset range:

=SUMPRODUCT((MOD(COLUMN($B2:$E2),2)=1)*($B2:$E2)*($A2:$D2<>""))
 
Upvote 0
Hi,

You don't need SUMPRODUCT for either column, a simple SUMIF will do the job:

Book3.xlsx
ABCDEFG
1CategoryActual-JanBudget-JanActual-FebBudget-FebYTD ActualYTD Budget
2Bonus24424
3Interest Inc44444
4Other Inc63463
5Net Salary Dave24424
6Net Salary Karla24424
Sheet831
Cell Formulas
RangeFormula
F2:F6F2=SUMIF(B$1:E$1,"Actual*",B2:E2)
G2:G6G2=SUMIF(B2:D2,"<>",C2:E2)
 
Upvote 0
That G2 one wouldnt work Jtakw. You could do it with a sumifs mind.
 
Upvote 0
Thank you, Steve and Jtakw! Steve, yours worked great on my sample spreadsheet but my own formula (and the one you built off it) failed on my much more complex real budget spreadsheet. Sorry, I should have validated that first. Are you able to show me how to solve it with the OFFSET function?

(Jtakw, The SUMIF didn't work. I had already tried using the SUMIFS but I had trouble pasting it as the Shift, control, enter did nothing when I tried to copy it into the other cells and I don't want to convert our budget spreadsheet to a table.)
 
Upvote 0
Corrected below:

Try it.

Book3.xlsx
ABCDEFG
1CategoryActual-JanBudget-JanActual-FebBudget-FebYTD ActualYTD Budget
2Bonus24424
3Interest Inc44444
4Other Inc632487
5Net Salary Dave24424
6Net Salary Karla24424
Sheet831
Cell Formulas
RangeFormula
F2:F6F2=SUMIF(B$1:E$1,"Actual*",B2:E2)
G2:G6G2=SUMIFS(C2:E2,B2:D2,"<>",C$1:E$1,"Budget*")


NOTE: Normally entered, Not CSE
 
Upvote 0
Solution
Thank you, Jtakw! That worked great! I realized that I had to take out some blank columns my husband had in our budget spreadsheet that made it look pretty but were interfering with the formulas you suggested! (That might also have interfered with Steven's solution too but I didn't go back to re-do and check.) So relieved to have it solved!
 
Upvote 0
You're welcome, glad it worked for you, thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,798
Messages
6,121,635
Members
449,043
Latest member
farhansadik

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top