Average only cells with value

Goddess

Board Regular
Joined
Dec 3, 2015
Messages
94
Office Version
  1. 2019
Platform
  1. Windows
Hi,

I have a range of cells with values, and am trying to get the average of those cells with values only.

For example, Company ABC has 2 areas, and since both areas only have data till March, I will need to sum the values in both areas and divide it by 3 (Jan, Feb and March). As I will get more data periodically, I may need to divide the total sum by 4, 5, 6 months, etc as and when I receive data. As the list is very long, I tried using pivot table, but it didnt work as pivot table will average it by 12 months. Anyway to work around it?

The end result I need is highlighted in yellow.

Book1
ABCDEFGHIJKLMNOPQ
1EntitiesAreaFloor Area (sqm)*Jan 22Feb 22Mar 22Apr 22May 22Jun 22Jul 22Aug 22Sep 22Oct 22Nov 22Dec 22Total
2ABCLot 15.005.002.006.1013.10
3ABCLot 24.002.001.305.208.50
4ABC-
5Sub total7.003.3011.30---------21.60
6DEFLot 16.008.008.406.502.507.802.8036.00
7DEF-
8DEF-
9Subtotal8.008.406.502.507.802.80------36.00
10XYZLot 13.005.102.108.309.004.702.1031.30
11XYZ-
12XYZ-
13Subtotal5.102.108.309.004.702.10------31.30
14
15Average
16ABC7.2
17DEF6
18XYZ2.22
19
Sheet1
Cell Formulas
RangeFormula
D13:O13,D9:O9,D5:O5D5=SUM(D2:D4)
P2:P13P2=SUM(D2:O2)
Cells with Data Validation
CellAllowCriteria
D9:O9Any value
D13:O13Any value
D2:O5Any value



Thanks!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
If in B18 is a typo (must be 5.22 NOT 2.22) then:

B16 =AVERAGEIF(D7:O7,">0")
B17 =AVERAGEIF(D11:O11,">0")
B18 =AVERAGEIF(D15:O15,">0")
 
Upvote 0
If in B18 is a typo (must be 5.22 NOT 2.22) then:

B16 =AVERAGEIF(D7:O7,">0")
B17 =AVERAGEIF(D11:O11,">0")
B18 =AVERAGEIF(D15:O15,">0")
The thing is... I have a long list. so I might have an error in the formula if I type in the formula line by line. Or is there a way to copy the formula, where it will skip certain number of rows (in this example, skip 3 rows)?

Thanks!
 
Upvote 0
Or is there a way to copy the formula, where it will skip certain number of rows (in this example, skip 3 rows)?
Like this?

22 06 28.xlsm
ABCDEFGHIJKLMNOP
2ABCLot 15526.113.1
3ABCLot 2421.35.28.5
4ABC0
5Sub total73.311.300000000021.6
6DEFLot 1688.46.52.57.82.836
7DEF0
8DEF0
9Subtotal88.46.52.57.82.800000036
10XYZLot 135.12.18.394.72.131.3
11XYZ0
12XYZ0
13Subtotal5.12.18.394.72.100000031.3
14
15Average
16ABC7.2
17DEF6
18XYZ5.216667
Average
Cell Formulas
RangeFormula
D5:O5,D13:O13,D9:O9D5=SUM(D2:D4)
P2:P13P2=SUM(D2:O2)
B16:B18B16=INDEX(P$2:P$13,MATCH(A16,A$2:A$13,0)+3)/COUNTIF(INDEX(D$2:O$13,MATCH(A16,A$2:A$13,0)+3,0),">0")
 
Upvote 0
Solution
You're welcome. Thanks for the confirmation.

A couple of other adjustments that you could consider?
- Change to the green subtotal row formula to only give a sum if numbers exist above.
- Add a new column Q to easily calculate the average for that section
- Allows for a simpler formula to get the averages in the yellow section.

22 06 28.xlsm
ABCDEFGHIJKLMNOPQ
1EntitiesAreaFloor Area (sqm)*Jan 22Feb 22Mar 22Apr 22May 22Jun 22Jul 22Aug 22Sep 22Oct 22Nov 22Dec 22TotalAverage
2ABCLot 15526.113.1
3ABCLot 2421.35.28.5
4ABC0
5Sub total73.311.3         21.67.2
6DEFLot 1688.46.52.57.82.836
7DEF0
8DEF0
9Subtotal88.46.52.57.82.8      366
10XYZLot 135.12.18.394.72.131.3
11XYZ0
12XYZ0
13Subtotal5.12.18.394.72.1      31.35.216667
14
15Average
16ABC7.2
17DEF6
18XYZ5.216667
Average (2)
Cell Formulas
RangeFormula
D5:O5,D13:O13,D9:O9D5=IF(COUNT(D2:D4),SUM(D2:D4),"")
Q5,Q13,Q9Q5=P5/COUNT(D5:O5)
P2:P13P2=SUM(D2:O2)
B16:B18B16=INDEX(Q$2:Q$13,MATCH(A16,A$2:A$13,0)+3)
 
Upvote 0
You're welcome. Thanks for the confirmation.

A couple of other adjustments that you could consider?
- Change to the green subtotal row formula to only give a sum if numbers exist above.
- Add a new column Q to easily calculate the average for that section
- Allows for a simpler formula to get the averages in the yellow section.

22 06 28.xlsm
ABCDEFGHIJKLMNOPQ
1EntitiesAreaFloor Area (sqm)*Jan 22Feb 22Mar 22Apr 22May 22Jun 22Jul 22Aug 22Sep 22Oct 22Nov 22Dec 22TotalAverage
2ABCLot 15526.113.1
3ABCLot 2421.35.28.5
4ABC0
5Sub total73.311.3         21.67.2
6DEFLot 1688.46.52.57.82.836
7DEF0
8DEF0
9Subtotal88.46.52.57.82.8      366
10XYZLot 135.12.18.394.72.131.3
11XYZ0
12XYZ0
13Subtotal5.12.18.394.72.1      31.35.216667
14
15Average
16ABC7.2
17DEF6
18XYZ5.216667
Average (2)
Cell Formulas
RangeFormula
D5:O5,D13:O13,D9:O9D5=IF(COUNT(D2:D4),SUM(D2:D4),"")
Q5,Q13,Q9Q5=P5/COUNT(D5:O5)
P2:P13P2=SUM(D2:O2)
B16:B18B16=INDEX(Q$2:Q$13,MATCH(A16,A$2:A$13,0)+3)
Thanks! Will take note of it
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,011
Members
449,204
Latest member
tungnmqn90

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