Need to replace AVERAGEIFS formula for excel 2003 - excel

I've been trying to get to grips with excel formulae for days, and now have a spreadsheet with 140 cells, each with a slightly different formula. Unfortunately, it now needs to be 'dumbed down' to Excel 2003.
I've tried to get my head round array formulae, and SUMPRODUCT, but I'm getting bogged down.
Fresh eyes, anyone?
This is the formula I need to convert from 2010 to 2003:
=AVERAGEIFS(Data!S:S,Data!L:L,"Atherstone",Data!T:T,"Service",Data!C:C,">="&K3,Data!C:C,"<="&K4)
K3 is a date range start, with K4 being the end, and Data! refers to Sheet 2 where all the data is held.
(I know all my cell ranges will have to be explicit - i.e. C2:c65536).

You will need to specify your range as a fixed area, as it will not understand S:S.
your formula will end up looking something like this:
=AVERAGE(IF(Data!L2:L2000="Atherstone",IF(Data!T2:T2000="Service",IF(Data!C2:C2000>=K3,IF(Data!C2:C2000<=K4,Data!S2:S2000)))))
(Untested)
you will also need to make it an Array formula, so excel can look at each of the values in the range individually by entering the formula using CTRL+SHIFT+Enter, instead of the more usual Enter after you have finished typing everything

Related

How to use a cell reference in INDIRECT function

I have several cells that calculate totals from a single cell from multiple worksheets, in this case "Y3" from each of the sheets that are in Week, where n is an integer from 1 through 10:
=SUMPRODUCT(COUNTIF(INDIRECT("'Week"&{1,2,3,4,5,6,7,8,9,10}&"'!Y3"),"W"))
I would like to have a cell in my workbook that contains, A1:
1,2,3,4,5,6,7,9,10
So that way I can update only one cell when I add a worksheet to be counted. I've tried a few things and nothing seems to work.
Your formula : =SUMPRODUCT(COUNTIF(INDIRECT("'Week"&{1,2,3,4,5,6,7,8,9,10}&"'!Y3"),"W"))
This formula only work if you have 10 sheets with named Week1,Week2,Week3….Week10
But if you have less than 10 sheets e.g. Week1,Week2,Week3….Week9, your formula will fail and return "#REF!" error
The formula workaround is wrapping with a IFERROR() and become :
=SUMPRODUCT(IFERROR(COUNTIF(INDIRECT("'Week"&{1,2,3,4,5,6,7,8,9,10}&"'!Y3"),"W"),0))
However, if you wanted the formula acting dynamic and in A1 enter : 1,2,3,4,5,6,7,9,10
But 1,2,3,4,5,6,7,9,10 is a text string, you need converted it to an array. Using FILTERXML() can do the work of which available since Excel 2013
This is an array formula you need to confirm by pressing CTRL+SHIFT+ENTER instead of just ENTER:
=SUM(IFERROR(COUNTIF(INDIRECT("'Week"&FILTERXML("<a><b>"&SUBSTITUTE(A1,",","</b><b>")&"</b></a>","//b")&"'!Y3"),"W"),0))
EDIT 1 :
And,
if you haven't Excel 2013, you could use this longer array (CSE) formula instead
=SUM(IFERROR(COUNTIF(INDIRECT("'Week"&TRIM(MID(SUBSTITUTE(","&A1,",",REPT(" ",99)),ROW(INDIRECT("1:"&LEN(A1)-LEN(SUBSTITUTE(A1,",",))+1))*99,99))&"'!Y3"),"W"),0))
After that,
you can make adjustment to A1 number without changing formula contents
AFAIK you can't do that with a formula if you place the sheet list in a single cell I stand corrected: see bosco_yip's answer! (although you could with a UDF).
But, if you place your sheet list in a column, you can do this (using OFFSET, the list is dynamic, but must be the only data in that column. There are alternatives if that doesn't suit you):
=SUMPRODUCT(COUNTIF(INDIRECT("'Week"&TRANSPOSE(OFFSET(A1,1,0,COUNTA(A:A)-1,1))&"'!Y3"),"W"))
Applying the FILTERXML method, to create a non-array formula
=SUMPRODUCT(COUNTIF(INDIRECT("'Week"&FILTERXML("<a><b>"&SUBSTITUTE(A2,",","</b><b>")&"</b></a>","//b")&"'!Y3"),"W"))

Turn off pop-up errors/alerts in MS Excel 2010

I have a table of results in MS Excel 2010 with formulas in each cell that I need to edit. I have INDIRECT cell references in the formulas that do not update when copied to other cells. So, I believe the easiest way in this case for me to edit all the formulas in the table is with two find-and-replaces (changing the beginning and end of each formula to have what I need). However, when I try to do the find and replace, Excel shoots a "The formula you typed contains an error" pop-up at me and refuses to execute the replace. I know there's an error, I'm not finished with the formula yet! So:
1) How can these errors be disabled?
2) Is there a way to make indirect cell references update the way a normal cell reference would (eg. make INDIRECT("'"&F5&"'!L7") update L7 to L8 in the next row) so that I can copy the new formula throughout the table of results, and avoid the find-and-replace entirely?
Sorry guys, I realize this is a somewhat strange question for stackoverflow.
1) I don't know.
2) I'm not 100% sure from the question, but I can think of two scenarios:-
(a) You have a list of references which your INDIRECT formula uses, and you want it to select each one in turn as you pull the formula down. This is trivial so it's probably not what you meant:-
=INDIRECT(A$1&"!"&A2)
assuming your sheet name is in A1 and the references are in A2,A3 etc.
(b) You have a reference to the beginning of a range of cells in sheet2, and when you pull the INDIRECT formula down, you want it to automatically get the next cell in the range:-
=INDIRECT(SUBSTITUTE(ADDRESS(1,COLUMN(INDIRECT($A$2)),4,1,$A$1),"1","")
&(ROW(INDIRECT($A$2))+ROW()-ROW($C$2)))
where this formula is placed in cell C2 and pulled down.
The idea is that you break the cell reference down into its column name (using the excellent suggestion here ) and its row number, then get the row number to increment using the ROW function.
Sheet 2:-
Sheet 1:-

Formulas won't calculate automatically

I have a big sheet with a lot of formulas that have a dependency hierarchy between them. It starts with a cell with a date value. Then, cell x:y (and others), has formula depending on this date. Then cell w:z (and others) has a formula depending on cell x:y. And so on...
This main cell with a date value is filled using apache poi.
And now my problem: when I open the generated excel file, the date is there, but none of the formulas are calculated. They all have the error "A value used in the formula is of the wrong data type". It seems that when the formula try to evaluate it self the date isn't there yet.
Solutions:
1) If I click in the cell, and just press ENTER, the formula is correctly evaluated. But then I would have to do this for all cells.
2) I click in the date cell, copy it, and then paste it in the same place, and all formulas in the sheet are evaluated!
3) I could iterate in all cells in my application, evaluating each one with evaluateFormulaCell method from FormulaEvaluator class. But I have a lot of formulas and the performance of this is terrible.
Does someone have a solution for this?
Thanks!!
Your date value isnt recognized by the excel formulas as a date, what you could do is have another cell dat will first take the datevalue DATEVALUE() of the cell filled using Apache poi.
Then direct your first level formulas to that cell instead of the one filled using Apache poi
Because Excel don't calculale automatically, so just change this.
Excel 2010: File -> Options -> Formulas: Find Workbook calculation, and change to Automatically.
It worked for me.
To solve this, I changed all formulas in my template, to use instead of the regular formula sintax (=SUM(A:D)) the following sintax:
$[SUM(A:D)]
http://jxls.sourceforge.net/reference/formulas.html

Excel 2013 Forumla Not Working in some Cells

SO I'm trying to get some work done in Excel 2013, and after getting an initial formula to work, I dragged it across several other cells. I did all the standard locking of references and such, even copied the exact formula into the new cell formula window with copy paste. The formula works in the first cell, not in those it's dragged over. It also works in seemingly random cells when pasted around (see screen shot).
Formula is below... this was a brand new sheet, the cells had not been initialized until the formula was pasted. Is this an issue with Excel 2013? Since the formula works in some pastes perfectly, and not in others, I don't think that's the issue... I changed the cell format after the pastes in a couple cells to see if that changed results at all - it does not.
Update: I added in the false value, and the IF is evaluating to false on the zero cells... why it's correctly true in some, and false in others is still a mystery.
=MIN(IF('Metrics'!$DL$2:$DL$1725=$L$2&$O$2,'Metrics'!$DH$2:$DH$1725))
The issue is that for the formula to correctly evaluate it should be set as an array (ctrl-shift-enter).
However, Excel 2013 seems to randomly recognize the formula as an array formula, and sometimes not. Thus the formula occasionally will work, in a brand new, uninitialized cell, using/displaying the standard formula, and a correct result. Other times it will still display the same formula, but produce incorrect results since it is not being evaluated as an array.
Any of the cells that did not magically convert to an array formula, when changed to array, will update with correct values.
Only manually changed cells reflect the {=MIN(IF(...)...))} indication of an array formula. Cells in which the formula produced correct results still display as a non-array formula.
I had a similar if not exactly the same issue. Try hitting F9 to recalc the sheet, or go to File>Options, go to "Formulas" and under "Workbook Calculations" set it to "Automatic".
Solved my problem, which manifested the same way yours did.
Good luck!
Since you are,using $ sign to lock the cells in the formula, it looks like you are just pointing it to the same cells giving you same results... Click on the formula and check or change to the correct reference cells as you desire...
turns out my 2003 excel problem was due to some circular formulas. Had "Circular:" at the very bottom line. When these all fixed, the other cells started to calculate properly.

What is wrong with this Excel formula to sum() next 2 columns in the same row?

I did try to enter in a cell formula:
=SUM(ADDRESS(ROW(),COLUMN()+1):ADDRESS(ROW(),COLUMN()+2))
Intention is summing next 2 cell in the same row.
But the spreadsheet complains with error on it!
Used functions: ADDRESS(ROW(),COLUMN()+1). Work fine but together - not!
In B7 cell:
(I need to write a generic formula that is independent from location and calculates the sum of the next tho cell in the same row.
I am not interested in specific addresses or in a way to copy any specifically written formula across a spreadsheet.
I need a formula that works independently from a location!
Is it possible in Excel at all?)
Thanks.
ADDRESS returns address as a string. You cannot SUM it because SUM(A2:A3) is very different from SUM("A2:A3").
You could look into SUM(INDIRECT("A2:A3")), but you should not, for the mere reason that Excel's formulas are already relative unless made absolute.
If you want to sum two cells to the right of B7, enter =SUM(C7:D7) to B7. The formula will change if you copy it to another cell.
If you meant to enter the formula with a macro, then use the R1C1 notation and enter =SUM(RC[1]:RC[2]).
sorry im dont speak english , but a have what you need
= SUM(INDIRECT(CONCATENATE(ADDRESS(ROW();COLUMN()+1);":"; ADDRESS(ROW();COLUMN()+2))))
Regards

Resources