I know this should be simple but I guess I'm having a brain freeze tonight. So I pleading for your help. Here is my formula problem.
EXAMPLE
I want to ADD
A2,A4,A6,A8,A10,A12 and divide it by the amount of cells in that range larger than zero. So if there is a positive number in A2,A4,A8 but not in A6,A10,A12 then the formula would divide by 3 not all cells.
I know this should be simple but I guess I'm having a brain freeze tonight. So I pleading for your help. Here is my formula problem.
EXAMPLE
I want to ADD
A2,A4,A6,A8,A10,A12 and divide it by the amount of cells in that range larger than zero. So if there is a positive number in A2,A4,A8 but not in A6,A10,A12 then the formula would divide by 3 not all cells.
Anyone have a suggestion?
Thanks
SDW
So you want it only to add the positive numbers. Too tricky for me sorry
Not working for me. I have Excel 2000.
Here is my formula written the way you suggested. I'm sorry but in my first post I used a single column. It should be a row but skipping some columns in the row.
wouldn't SUM(A2:A12) add all the sells between A2 and A12 inclusively -- not every other one as it should?
Also, wouldn't COUNTIF(A2:A12,">0") suffer similarly and count all the cells between A2 and A12 that are ">0" -- not every other one as it should?
Is there any critical reason why it has to be every other cell? It would be best if all of the numbers to be operated on were grouped together in one row or column so a simple range would suffice (i.e. A1:A6). In this case, the formula would simply be as benhur stated:
=sum(A1:A6)/countif(A1:A6,">0")
[Note: You may get anomalous results if any of the cells have negative values. In this case, use:
=sumif(A1:A6,">0")/countif(A1:A6,">0")
]
Everything I can think of that would operate on even-rowed cells involves modulus arithmetic on the row numbers; I prefer keeping math to the actual values in the cells rather than the cell labels as it can get very unwieldy very quickly.
Originally posted by Southern Gentleman:
=(d2+f2+h2+j2+L2+n2)/(countif(d2+f2+h2+j2+L2+n2,"0"))
Not working for me.
Not working for me. I have Excel 2000.
Here is my formula written the way you suggested. I'm sorry but in my first post I used a single column. It should be a row but skipping some columns in the row.
=(d2+f2+h2+j2+L2+n2)/(countif(d2+f2+h2+j2+L2+n2,"0"))
I am using office10 on one machine and XP on another and it works in both of them.
It would be easier if all the numbers were in consecutive cells, this way you could use (A1:A6)
Originally posted by David.C:
wouldn't SUM(A2:A12) add all the sells between A2 and A12 inclusively -- not every other one as it should?
Also, wouldn't COUNTIF(A2:A12,">0") suffer similarly and count all the cells between A2 and A12 that are ">0" -- not every other one as it should?
Yes in my original formulea (A2:A12) will pick up all cells but it will only count or add together those with a positive value in them, as on the COUNTIF the if condition is only looking for positive values to count the total number to divide by.
[Note: You may get anomalous results if any of the cells have negative values. In this case, use:
=sumif(A1:A6,">0")/countif(A1:A6,">0")
if you have a negative value and you want to include this in the dividing value then use the following by replacing the > in the COUNTIF condition to <>
=(SUM(A1:A6)/(COUNTIF(A1:A6,"<>0")))
> Greater than
< Less then
<> Greater than or Less then,
=> equal to or grater than
=< equal to or less than
<=> less than, equal to or great than (but then you would just use (COUNT(A1:A6) rather than COUNTIF)
Here is a screen print of what I'm doing in Excel.
Column A = Photographer and team (manual entry)
Column B = Photographer or team beginning avg. (manual entry)
Column C = Challenge entry's for week 1(manual entry)
Column D = Highest score of challenges entered for week 1 (formula /max)
Column E and F = same as C and D but week 2
Column G and H = same as C and D but week 3
Column I and J = same as C and D but week 4
Column K and L = same as C and D but week 5
Column M and N = same as C and D but week 6
Column C30:33 = Top 4 photographer scores during week 1
Now that I have all those formulas automated I need Column O formula to be automated instead of having to put in how many weeks the photographer entered, manually.
I hope this screen prints gives you an idea why I can't use column's or rows in sequence.
wouldn't SUM(A2:A12) add all the sells between A2 and A12 inclusively -- not every other one as it should?
Also, wouldn't COUNTIF(A2:A12,">0") suffer similarly and count all the cells between A2 and A12 that are ">0" -- not every other one as it should?
Yes in my original formulea (A2:A12) will pick up all cells but it will only count or add together those with a positive value in them, as on the COUNTIF the if condition is only looking for positive values to count the total number to divide by.
I mention it only because we are given no guarantee on the values of the uninvolved cells -- but since the table is relatively small hard-coding the cells makes more sense than evaluating which ones are involved.
this is the formula used it is long but it works and if it returns an error it will return a blank field so that it keeps the spreadsheet looking tidy.
Not to sound picky, or to make a stupid comment, but do you have the formula in CAPITAL LETTERS? If you actually used lower case letters it won't work.
You have to move the week designation to another cell though.
EDIT: Just to clarify the SUMPRODUCT is counting every cell that is greater than zero and where the cell above it has a value of "High Score".
Made some alterations and it works good again did an IF(ISERROR(
=IF(ISERROR(SUM(D3,F3,H3,J3,L3,N3)/(SUMPRODUCT((D3:N3>0)*($D$2:$N$2="High Score")))),"",SUM(D3,F3,H3,J3,L3,N3)/(SUMPRODUCT((D3:N3>0)*($D$2:$N$2="High Score"))))
Not to sound picky, or to make a stupid comment, but do you have the formula in CAPITAL LETTERS? If you actually used lower case letters it won't work.
Excel will automatically change them to capitals if you type them in lower case
Yea, this is trickier than it first looks. If the cells were contiguous (i.e. next to each other) it would be easy to do with the formula;
=AVERAGE(IF(A2:A7<>0, A2:A7,""))
I got that example from Excel help, and it works. You have to remember when you type it in to press 'CTRL-SHIFT-ENTER' instead of just 'ENTER' at the end, so it gets input as an array formula.
Anyway, I tried creating a named range of non-contiguous cells and slotting the range name into the above formula, but Excel just doesn't like it. Looks like the longhand approach is the only way (i.e. checking the contents of every cell, as I saw posted above)
Yea, this is trickier than it first looks. If the cells were contiguous (i.e. next to each other) it would be easy to do with the formula;
=AVERAGE(IF(A2:A7<>0, A2:A7,""))
I got that example from Excel help, and it works. You have to remember when you type it in to press 'CTRL-SHIFT-ENTER' instead of just 'ENTER' at the end, so it gets input as an array formula.
Anyway, I tried creating a named range of non-contiguous cells and slotting the range name into the above formula, but Excel just doesn't like it. Looks like the longhand approach is the only way (i.e. checking the contents of every cell, as I saw posted above)
I tried using a "TEAM" name but it would not work, sometimes excel is a really good tool to work out things othertimes it is a pain in the a$$e
If you don't mind hidden columns, this is pretty easy.
In this example, column a has the values in question.
create a column B where the cell values are "@if(a1 > 0,1,0)". A1 would be for row 1, a2 for row 2, etc. This will set a value in column b as either 0 or 1 based upon the value in column A.
Then, to do the calculation you wish to accomplish, you would just do a sum of the source range and divide it by the sum of the corresponding range in column b. Once you have this set up, just hide column b.