Converting string into usable arrays in formula in Excel - arrays

The goal is to output the sum of all price in Col B if the corresponding product in Col A is found in the user selection. The user selection may comprise one or multiple products, separated by comma.
I have tried 2 formula, but they both do not work because the criteria in the SUMIF is not treated as an array.
=SUMPRODUCT(SUMIF(A:A,"{"""&SUBSTITUTE(D2,", ",""";""")&"""}",B:B))
=SUMPRODUCT(SUMIF(A:A,CHAR(34)&SUBSTITUTE(D2,", ",CHAR(34)&","&CHAR(34))&CHAR(34),B:B))
Further notes:
There is only one cell (D2) for user selection, where they can specify the product(s) that they want to query for, separated by a comma.
Using split cells, the formula below would work, but this is not what I want because I need users to key in their selection(s) in one cell (D2).
=SUMPRODUCT(SUMIF(A:A,D6:D16,B:B))
Similarly, typing the user selection into the formula would work, but doing so would be too tedious for the user.
=SUMPRODUCT(SUMIF(A:A,{"Apple";"Pear";"Grapes"},B:B))
[Edit] Sample Excel File:
[Edit 2]: Any clue why "{"""&SUBSTITUTE(D2,", ",""";""")&"""}" cannot be passed through the formula as array while {"Apple";"Pear";"Grapes"} works fine?

This matrix formula seems to do the trick (confirm by pressing control+shift+enter):
=SUM(IF(ISERROR(FIND(A1:A4,D1)),0,B1:B4))

Related

Use of Array/VLOOKUP to create sums from lists

I'm using Excel 2007+, My plan is to create 3 connected columns, the first column is a basic description(text), to help you understand what i'm trying to do column 1 will be colours(so in the column "Red" would be a correct value to enter and this is simply typed in). Column 2 would be a modifier in the form of a list separated by commas in this example shapes and this is entered using a combination of Vlookup and VBA to call from a list in column A in the next sheet(so in this column "Triangle,Square,Circle").
Finally my problem is i want column 3 to be a sum of column 2 this would not be the sum of the shapes however, it would be the sum of values assigned to the shapes(this value would be right next to the shape in VLOOKUP list, B Column)
Hope my explanation helps, let me know if you need more info.
I have added an image for an example, where the left columns are lists to be looked up and the right is an example of what it would look like when correct.
Tried VLOOKUP but I'm missing something.
none yet
See image for expected results, the value column should auto-complete when the shape and colour columns have been filled.
https://i.stack.imgur.com/TjYTG.png

Excel find results not in one array from another

Without using VBA, is there any way to find and output the results missing from one array compared to another into cells.
I have two sheets, on Sheet1 is a list of numbers in column B and "N/A" In column J if we are done with them. On Sheet2 is we paste a list of numbers in column B. I need to be able to find the numbers missing from Sheet2 that do not have an "N/A" tag in Sheet1 and output them to column C.
I tried {=INDEX(Sheet1!B:B,MATCH(1,(Sheet1!B:B<>B:B)*(Sheet1!J:J<>"N/A"),0))} but (Sheet1!B:B<>B:B) doesn't seem to be doing what i think it should. I understand that the above formula won't give more than 1 result yet. I would need to add something to eliminate the results already in column C, but one step at a time.
Sheet1!B:B<>B:B compares corresponding cells in two sheets. Unless the numbers appear at the same exact rows in both sheets, your code will not work.
I don't think it is possible to deal with this with array formula, because Match doesn't accept an array as its first argument. But you can enter this in C1 and copy and paste to the whole column:
=IF(ISERROR(MATCH(Sheet1!B1,Sheet2!B:B,0)),IF(Sheet1!J1<>"N/A",Sheet1!B1,""),"")
There will be empty cells though.

Excel sum across multiple sheets with criteria array

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).

Excel - Perform Summation of Column of If Statements In One Cell

I feel like I've done this before but am at a total loss after looking at a lot of pages already.
Consider a set of data given in two columns, x and y. X column is always ascending in value, y is random. I need a single cell to calculate the sum of a column of IF statements within a specified range of x without actually displaying the column of IF statements or using VBA. In other words: I want to turn this (IMG1) into this (IMG2)
In the first picture, the z column has this formula for each cell in a descending order: =IF(AND(B2>0,A2>$D$2,A2<$D$3),A2-A1,0)
I feel like I can use SUMIFS or an array formula somehow but I'm at a loss.
Please forgive if I improperly posted this somehow - this is my first post.
-Adam
Try this Array Formula which requires a special key stroke Ctrl+Shift+Enter instead of Enter alone.
=SUM(IFERROR((A2:A11>0)*(B2:B11>0)*(A2:A11>D2)*(A2:A11<D3)*(A2:A11-A1:A10),0))
Confirm this formula with Ctrl+Shift+Enter

IF ARRAY Formula

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)

Resources