Find the difference between to cells based on the value from the other cell

HelloKhritty

New Member
Joined
Jan 7, 2022
Messages
9
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
Platform
  1. Windows
Hello,
So i do have a project where i want to get the difference between two cells. However it will be based on the date from the other cell.

1656871023762.png


as you can see in the table, The date on column B will be my basis. I need to find the diff of column E and column G based on the date given in column B, but my problem is, if the date in column D has no matched date in colunm F i need to have a 0.00 equals to the date that has no matched date to subtract it for column E and vice versa.
the formula i need is this:
in B column thers is 63022
D column there is no 63022 so the value will be 0.00 and will be less to G value which has the same date 63022.
and same goes to if both column have the same date as given in column B.
The difference will be placed in column I
I hope my problem is clear to understand and I hope you can help me. If You can have an excel formula for this then it will be very great, but if vba only, i would gladly accept it. thanks in advance. Really appreciate you guys in here. :)
 

Attachments

  • 1656870954553.png
    1656870954553.png
    31.4 KB · Views: 5

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I'm not sure which direction you want the difference (E-G or G-E), but this approach takes the date on a given row in column B and looks for a MATCH in columns D and F, and then returns the corresponding values in E and G. If a match is not found, this attempt to find a "match" will result in an error, so the IFERROR wrapping is used to return a 0 in that case. Then the difference is taken (E-G)...if you want G-E, then switch the order or change the sign of the result.
Book1
BCDEFGHI
1
2CsideDsideDiff
3SMS Posted DateDateSumDateSum
463022601220.160322100
562922603220.26292211-11
6500009960122120
7400007.77
85000097.67
9400007.770
10500001.330
Sheet2
Cell Formulas
RangeFormula
I4:I10I4=IFERROR(INDEX($E$4:$E$10,MATCH($B4,$D$4:$D$10,0)),0)-IFERROR(INDEX($G$4:$G$10,MATCH($B4,$F$4:$F$10,0)),0)

As a side note, it would be preferred if you would use the XL2BB add-in to provide a small mini-sheet of your worksheet rather than a picture. The mini-sheet can be readily copied into a worksheet, and that convenience improves the odds of getting a response.
 
Upvote 0
Does this do what you want?

22 07 04.xlsm
BCDEFGHI
1
2CsideDsideDiff
3SMS Posted DateDateSumDateSum
463022601220.160322100
562922603220.26292211-11
6500009960122120
7400007.77
85000097.67
9400007.770
10500001.330
Diff on date
Cell Formulas
RangeFormula
I4:I10I4=SUMIF(D$4:D$10,B4,E$4:E$10)-SUMIF(F$4:F$10,B4,G$4:G$10)


♦️ Another side note. It is usually very helpful in clarifying your question if you include the expected results, manually entered with your sample data.
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,164
Members
448,870
Latest member
max_pedreira

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