Formula to calculate dinamically the average costs until the last non-blank cell

vladimiratanasiu

Active Member
Joined
Dec 17, 2010
Messages
348
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello!

I have a large table with monthly spendings. Some months they still don't happen, so that the correspondent cells are empty. I need a formula to calculate dinamically the average incurred costs until the last period with value, but counting also the previous months without spendings (see the results from column C).

Thank you!

Book1
ABC
1MonthEuroAverage
2Jan-2236.5736.57
3Feb-2244.7040.635
4Mar-22
5Apr-2246.2531.88
6May-22-7.1224.08
7Jun-22
8Jul-22
9Aug-2233.3219.215
10Sep-22
11Oct-22
12Nov-2214.3615.28
13Dec-22
14Average
Sheet1
Cell Formulas
RangeFormula
C2C2=B2/1
C3C3=SUM(B2:B3)/2
C5C5=SUM(B2:B5)/4
C6C6=SUM(B2:B6)/5
C9C9=SUM(B2:B9)/8
C12C12=SUM(B2:B12)/11
 
The index needs to be from row 1 like
Excel Formula:
=AVERAGE(--C4:INDEX(C1:C15,LOOKUP(99^99,C3:C15,ROW(C3:C15))))
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,826
Messages
6,181,192
Members
453,021
Latest member
pingpong7117

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