Subtracting cells

Asquare

New Member
Joined
Aug 23, 2016
Messages
19
I want to subtract cell D3 from cell D2 but only if cells B3 & B2 have the same value. if cells B3 & B2 are not equal, I want the formula to detect the next two cells that contain the same values and subsequently deduct their respective values in column D. In this case the values in cells B5 & B4 are not equal, hence the formula should check cells B5 & B6 and if they contain the same value deduct the values in cell D6 & D5 (D6 - D5).

Thank you in advance.


Column B Month Column D Value
90001-Jul-1581408140
90001-Aug-15149996859
90001-Sep-1520978
90101-Jul-159000
90101-Aug-1514633
90101-Sep-1519715
90201-Jul-158338
90201-Aug-1512799
90201-Sep-1517059
90301-Jul-158913
90301-Aug-1513960
90301-Sep-1518475

<tbody>
</tbody><colgroup><col><col><col><col></colgroup>



<tbody>
</tbody><colgroup><col><col><col><col></colgroup>



<tbody>
</tbody><colgroup><col><col><col><col></colgroup>
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Not quite, When B3<>B2, I want the formula to search for the next consecutive cells in column B that contain the same values. say B3<>B2, so the formula should check if cell B3=B4 and deduct D4 from D3.

Thanks for the help.
 
Upvote 0
NumberMonthEndValue
123Jul-155057.96
123Aug-159319.944261.98
123Sep-1513035.123715.18
123Oct-1514216.971181.85
123Nov-1516025.78
123Dec-1519130.77
123Jan-1624595.73
123Feb-1628733.44
123Mar-1633127.77
123Apr-1637580.52
123May-1638464.11
123Jun-1641100.58
123Jul-1642997.01
123Sep-1648713.00
123Oct-1651867.08
123Nov-1652919.68
321Jul-155592.34
321Aug-159092.523500.18
321Sep-1512250.333157.81
321Oct-1516145.08
321Nov-1518845.56
321Dec-1519392.99
321Jan-1621799.56
321Feb-1626165.31
321Mar-1629292.05
321Apr-1632028.57
321May-1633023.38
321Jun-1635753.69
321Jul-1638326.16
321Aug-1642172.45
321Sep-1644858.02
321Oct-1647721.29
321Nov-1648432.14

<tbody>
</tbody><colgroup><col><col><col><col></colgroup>
 
Upvote 0
I am trying to calculate a value for every month. say august, the expected value will be end of Aug - end of Jul, July value should be ignored but I don't want the formula to depict that as July values will come automatic.
 
Upvote 0
It is still unclear why there are no Values for Number 123 from Nov-15 through Nov-16.
Same for Number 321 from Oct-15 through Nov-16.
 
Upvote 0
NumberMonthEndValue
123Jul-155057.96
123Aug-159319.944261.98
123Sep-1513035.123715.18
123Oct-1514216.971181.85
123Nov-1516025.781808.81
123Dec-1519130.773104.99
123Jan-1624595.735464.96
123Feb-1628733.444137.71
123Mar-1633127.774394.34
123Apr-1637580.524452.74
123May-1638464.11883.59
123Jun-1641100.582636.48
123Jul-1642997.011896.42
123Sep-1648713.005715.99
123Oct-1651867.083154.08
123Nov-1652919.681052.60
321Jul-155592.34
321Aug-159092.523500.18
321Sep-1512250.333157.81
321Oct-1516145.083894.75
321Nov-1518845.562700.48
321Dec-1519392.99547.43
321Jan-1621799.562406.57
321Feb-1626165.314365.75
321Mar-1629292.053126.74
321Apr-1632028.572736.52
321May-1633023.38994.81
321Jun-1635753.692730.30
321Jul-1638326.162572.48
321Aug-1642172.453846.29
321Sep-1644858.022685.57
321Oct-1647721.292863.28
321Nov-1648432.14710.85

<tbody>
</tbody><colgroup><col><col><col><col></colgroup>



There you go
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

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