Sum of differences formula

artz

Well-known Member
Joined
Aug 11, 2002
Messages
830
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I am seeking a cell formula or VBA that will provide the sum of 20 differences starting with the most current value, in this case, the value in I39. The range is dynamic, first data is in I8 following a header in I7. If the formula includes cells that are either blank or text (like I7) a blank should be returned for that cell.

Code:
=SUM($I$39-I37,$I$39-I36,$I$39-I35,$I$39-I34,$I$39-I33,$I$39-I32,$I$39-I31,$I$39-I30,$I$39-I29,$I$39-I28,$I$39-I27,$I$39-I26,$I$39-I25,$I$39-I24,$I$39-I23,$I$39-I22,$I$39-I21,$I$39-I20,$I$39-I19,$I$39-I18)

A capture of the worksheet is shown below:

Excel Workbook
IJK
7CloseCICI Desired
843.13#REF!*
943.14#VALUE!*
1043.7#VALUE!*
1144.44#VALUE!*
1244.67#VALUE!*
1344.93#VALUE!*
1444.55#VALUE!*
1544.94#VALUE!*
1645.65#VALUE!*
1745.69#VALUE!*
1845.81#VALUE!*
1946.51#VALUE!*
2045.88#VALUE!*
2146.16#VALUE!*
2245.49#VALUE!*
2346.08#VALUE!*
2445.8#VALUE!*
2547.12#VALUE!*
2648.33#VALUE!*
2748.16#VALUE!*
2849.35#VALUE!*
2950.15179.42179.42
3049.05173.2173.2
3148.28166.19166.19
3248.76160.84160.84
3349157157
3448.61152.91152.91
3550.79148.84148.84
3650.43144.78144.78
3750.06138.93138.93
3852.7134.15134.15
3954.48129.78129.78
Sheet1




The simple sum formula shown below cannot adjust for variability in the number of rows containing data, nor can it exclude text or blanks. Column J shows how the output should look. Does anyone in the Forum have a suggestion for code to do this?

Thanks,

Art
 
Hi Aladin,

We are almost there. The formula: =IF(ISNUMBER(I16),IF(COUNT(I11:I14)=4,4*I16-SUM(I11:I14),""),"") works fine, however, we need one more IF to place a blank, "", in cell J16 if I16 is blank. Then I think we've got it.

Do you see how to do this?

Thanks,

Art

Art: The formula does do that:
Code:
=IF(ISNUMBER(I16),
     IF(COUNT(I11:I14)=4,
       4*I16-SUM(I11:I14),
       ""),
     "")

When I16 is not a number, it puts in J16 a blank (I.e., ""). Right?
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi Aladin,

Yes, you are correct; you've got it. I need to move this to the 20 term calculation but otherwise, unless I find a surprise, I think that you've got it.

Thanks again to you and sgh,

Art
 
Upvote 0
Hi Aladin,

Yes, you are correct; you've got it. I need to move this to the 20 term calculation but otherwise, unless I find a surprise, I think that you've got it.

Thanks again to you and sgh,

Art

I trust that will not be a problem. Our thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,222,098
Messages
6,163,927
Members
451,866
Latest member
cradd64

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