Sum values based on condition

Patrick020

New Member
Joined
Mar 20, 2018
Messages
15
Hi everyone <o:p></o:p>
<o:p></o:p>
I would like to sum values which are in two columns – but only take values from column B if column C is empty.
<o:p></o:p>
<o:p></o:p>
To provide some context, Column C is actual spend and Column B is forecast spend. When comparing against budget I want to SUM actual spend where available, but if the data is notavailable then take the forecast spend figure.
<o:p></o:p>
<o:p></o:p>
Here is an example:
<o:p></o:p>
<o:p></o:p>
A<o:p></o:p>
B<o:p></o:p>
C<o:p></o:p>
1<o:p></o:p>
Forecast <o:p></o:p>
Actual <o:p></o:p>
2<o:p></o:p>
Item 1 <o:p></o:p>
40,000<o:p></o:p>
45,000<o:p></o:p>
3<o:p></o:p>
Item 2<o:p></o:p>
50,000<o:p></o:p>
4<o:p></o:p>
Item 3<o:p></o:p>
50,000<o:p></o:p>
5<o:p></o:p>
Item 4<o:p></o:p>
25,000<o:p></o:p>
6<o:p></o:p>
Item 5<o:p></o:p>
30,000<o:p></o:p>
40,000<o:p></o:p>
7<o:p></o:p>
8<o:p></o:p>
Total <o:p></o:p>
210,000<o:p></o:p>

<tbody>
</tbody>
<o:p></o:p>
<o:p></o:p>
I need a formula in B8 - The answer here is 210,000 as we SUM the Forecast values in B3, B4, B5 (as they have no Actual figures) and the Actual values in C2, C6 (as they have Actuals).
<o:p></o:p>

Hopefully that is clear - would appreciate any help!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
if vba is allowed try this

Code:
Sub SumStuff()
Dim r As Range
Dim total As Long
total = 0
'change range here for your range if needed
For Each r In Range("B2:B6")
    If r.Offset(, 1).Value = "" Then
        total = total + r.Value
    ElseIf Not r.Offset(, 1) = "" Then
        total = total + r.Offset(, 1).Value
    End If
Next
'change location of sum if needed
Range("B8").Value = total

End Sub
 
Upvote 0
Hi,

Non-array formula, entered normally:


Book1
ABC
1ForecastActual
2Item 140,00045,000
3Item 250,000
4Item 350,000
5Item 425,000
6Item 530,00040,000
7
8Total210,000
Sheet64
Cell Formulas
RangeFormula
B8=SUM(SUMIF(C2:C6,"",B2:B6),C2:C6)
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,700
Members
448,979
Latest member
DET4492

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