I have an array formula that looks like this:
{=SUMIF(C11:C23,budgets,F11:F23)}
What I want it to do is sum cells F11:F23 where cells C11:C23 are values within the named range budgets.
Right now budgets has two values: 10361 and 10300 (these are transaction codes). However, the formula seems to only work for the first code 10361 but not for the second one.
I don't want to use SUMIFS because I have multiple worksheets where I would like this array formula to work, and the codes may change so changing them in one place (the named range budgets) will make things easier.
Any ideas? I don't know VBA, so was hoping for a formula solution.
Use SUMPRODUCT with COUNTIF():
=SUMPRODUCT((COUNTIF(budgets,$C$11:$C$23)>0)*$F$11:$F$23)
Or you can use this array formula:
=SUM(SUMIF(C11:C23,budgets,F11:F23))
Being an array it needs to be entered with Ctrl-Shift-Enter when exiting edit mode instead of Enter. If done properly Excel will put {} around the formula.
Related
I'm trying to figure out how to use array formulas in Excel 365. Here's a very simple situation I'm starting with. I have an array of values, and I want to get the sum of the values in each row. In reality, I have 2000 rows, and 600 columns, but to simplify let's say I just have the following:
I want to put the sums in the 3rd column (just 6, 60, 600) using an array formula. I know I can just enter a simple formula for one row and copy it down, but I'm interested in seeing how this is done with an array formula so I can just enter a single formula. What I want to do will get more complicated after that, but I want to start with this.
(I'm an experienced Excel user, but I haven't worked much with array formulas in Excel 365.)
Use BYROW/LAMBDA:
=BYROW(C2:E4,LAMBDA(a,SUM(a)))
Another option is MMULT
=MMULT(C2:E4,SEQUENCE(COLUMNS(C2:E4),,1,0))
I have a workbook with several sheets, each containing a large amount of data formatted identically. What I'd like to do is enter a formula on a summary sheet that sums data from across the data sheets, selecting the data to sum based on an array of criteria.
The list of sheets is named 'AdHoc_Sheets' and the list of criteria is named 'Uncontrollable_Compensation'.
First attempt:
=SUMPRODUCT(SUMIF(INDIRECT("'"&AdHoc_Sheets&"'!"&"C:C"),A40,INDIRECT("'"&AdHoc_Sheets&"'!"&"E:E")))
This works well when only a single criteria (in this case 'A40') is needed. The challenge I'm finding is changing that to be an array of criteria.
Second attempt:
={SUMPRODUCT(SUM(IF(ISERROR(MATCH(INDIRECT("'"&AdHoc_Sheets&"'!"&"C:C"),TRANSPOSE(Uncontrollable_Compensation),0)),0,INDIRECT("'"&AdHoc_Sheets&"'!"&"E:E"))))}
Which returns a zero when it's not CSE'd and an #N/A error when it is CSE'd. Something about the dynamics of juggling the arrays is messing me up, and I can't quite tell if I need to turn to MMULT or some other method. Thanks in advance.
Assuming that the entries in column C are text, not numeric, array formula**:
=SUM(IF(ISNUMBER(MATCH(T(OFFSET(INDIRECT("'"&AdHoc_Sheets&"'!"&"C1"),TRANSPOSE(ROW(C1:C100)-MIN(ROW(C1:C100))),0)),Uncontrollable_Compensation,0)),N(OFFSET(INDIRECT("'"&AdHoc_Sheets&"'!"&"E1"),TRANSPOSE(ROW(C1:C100)-MIN(ROW(C1:C100))),0))))`
With such a construction you cannot 'get away' with arbitrarily referencing entire columns without detriment to performance. Hence my choice of range from row 1 to row 100, which obviously you can change, though be sure to keep it as small as possible.
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
I am trying to find the SUM of a multipart IF statement using a separate spreadsheet:
=SUM(IF(AND([Doc.xlsx]Sheet1!$B$7:$B$348="APPL*", C15=[Doc.xlsx]Sheet1!$C$4:$BG$4),[Doc.xlsx]Sheet1!$I$7:$J$348))
NOTE: C15 = "A1"
I've tried breaking this formula down into these two separate parts:
=IF(C15=[Doc.xlsx]Sheet1!$A$4:$BG$4,TRUE)
and
=IF([Doc.xlsx]Sheet1!$B$7:$B$348 = "APPL*",TRUE)
However, these all fail out.
How can you find a single output using two criteria such as a column head and a row header?
Here is an image of what I'm working with. I need to sum all of the numbers met by the criteria from the grid by using the Column header and Row header.
As per my comments one must have uniform output to input ranges; same number of rows as the row headers and same number of columns as the column headers.
This will then find where the two intersect and sum the corresponding intersections.
With Array formula on cannot use AND() or OR() functions. Use * or + respectively to accomplish the same thing.
So something like:
=SUM(IF((A2:A12=B15)*(B1:K1=B16),B2:K12))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.
But one can do the same with SUMPRODUCT() without the need for Ctrl-Shift-Enter.
=SUMPRODUCT((A2:A12=B15)*(B1:K1=B16),B2:K12)
SUMPRODUCT does not need the Ctrl-Shift-Enter to enter but the normal entry method. It is still an array type formula.
Now to the second part IF/SUMPRODUCT do not use wild cards so you will need to use SEARCH() which will allow the use of wildcards.
=SUM(IF((ISNUMBER(SEARCH("APPL*",[Doc.xlsx]Sheet1!$B$7:$B$348)))*(C15=[Doc.xlsx]Sheet1!$C$4:$BG$4),[Doc.xlsx]Sheet1!$C$7:$BG$348))
The SUMPRODUCT:
=SUMPRODUCT((ISNUMBER(SEARCH("APPL*",[Doc.xlsx]Sheet1!$B$7:$B$348)))*(C15=[Doc.xlsx]Sheet1!$C$4:$BG$4),[Doc.xlsx]Sheet1!$C$7:$BG$348)
On one sheet in my file I have a number of arrays defined as named ranges. One another sheet I'd like to use a drop down, or something similar to select the name of one of the named range and have the data/contents of that named range populate a range on the second sheet. Is this possible WITHOUT VBA? Is there an array formula that will do this?
One, not entirely elegant, method that I've thought of is using the index function and copy this within a range of cells equivalent in size to the size of the largest named range. Something like:
=INDEX(range_1,ROW(),COLUMN())
This requires me to be able to pass the name of a named range into a function though. Is this possible?
Answers to either or both of these questions would be greatly appreciated.
Without that, the only other way I can think to do this is using a brute force, offset look up, which I'd prefer not to do.
Thanks for your help.
Indirect might do what you want it to.
In Sheet1 I created 3 named ranges:
Then in Sheet2, I
1) Put these names in Column A
2) Used a data validation list linked to column A to place a name in a cell (C2)
3) Used the array formula {=INDIRECT(C2)} (accepted with Ctrl+Shift+Enter) in the cells that I wanted to hold the array (C4:E5)
When C2 is changed via the drop-down, the array is automatically changed:
I have an array of cells (C2:D43) in which I want to count the number of times a particular string ("filler") occurs. However, I only want to consider the even rows in my array (so basically, the array is C2:D2;C4:D4, etc.). How can I do this? I'm working with Excel 2007.
This SUMPRODUCT formula will do it:
=SUMPRODUCT((C2:D43="filler")*(MOD(ROW(C2:D43),2)=0))
Try using MOD(ROW(),2)=0 to split up your cells so that your array has two sets: even and odd cells. Then find a way to tell Excel to choose only the values that are the opposite value of the one evaluated at the first row of the array. I'll see if I can find a way to formalize this.