Average Formula Using Sum/Countif - But Cells are nonadjacent

jjm3066

New Member
Joined
Jun 22, 2011
Messages
43
I am trying to do an average formula, where I need to eliminate any cells that hold a zero, so I am doing =sum(data range)/countif(data range,">0"). Easy formula... but the problem is that my range holds columns that are non-adjacent. They skip every other column where my data holds.

How do I allow the formula to work?
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I am trying to do an average formula, where I need to eliminate any cells that hold a zero, so I am doing =sum(data range)/countif(data range,">0"). Easy formula... but the problem is that my range holds columns that are non-adjacent. They skip every other column where my data holds.

How do I allow the formula to work?
Maybe this...

Book1
BCDEFGH
1504804324800
Sheet1

This array formula** will average every other cell starting from cell B1 and exclude 0 and negative values.

=AVERAGE(IF(MOD(COLUMN(B1:H1)-COLUMN(B1),2)=0,IF(B1:H1>0,B1:H1)))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.
 
Upvote 0
Ok thank you, it worked. :-)

Now what happens if the columns are NOT actually every other column. Can I tell it to only pick up the column headers that contain a certain value and then provide an average of those columns.
 
Upvote 0
Ok thank you, it worked. :-)

Now what happens if the columns are NOT actually every other column. Can I tell it to only pick up the column headers that contain a certain value and then provide an average of those columns.

In case of non-contiguous cells, try...

=SUM(A4,E4,G4,L4)/INDEX(FREQUENCY((A4,E4,G4,L4),0),2)

Adjust the target cells to suit.
 
Upvote 0
But all my column headers contain the same verbage.. it would be easier, I would have to select like 150 columns your way. Anything else?
 
Upvote 0
Ok thank you, it worked. :-)

Now what happens if the columns are NOT actually every other column. Can I tell it to only pick up the column headers that contain a certain value and then provide an average of those columns.
What version of Excel are you using?
 
Upvote 0
Try something like this...

Book1
BCDEFGHIJ
1ThisThatThemThisThisThatThisThemThis
2548979088580826
Sheet1

Get the average of row 2 if row 1 = "This" and row 2 is greater than 0:

=AVERAGEIFS(B2:J2,B1:J1,"this",B2:J2,">0")
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,898
Members
452,948
Latest member
Dupuhini

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