I have an Excel formula like this:
=SUM(SUMIF(A2:A11;{"1010";"1020"};B2:B11))
Now I need to make the formula more dynamic. Instead of changing the formula itself, I should be able to change some cell (linked in the formula). This change will be reflected in the formula.
Ex:
=SUM(SUMIF(A2:A11;D2;B2:B11))
Cell D2 should return something similar to {"1010";"1020"} in the first formula.
I tried this and it works only if in the column D I have one value (ex: 1020), but if there are two values (ex: 1010;1020) it returns 0.
This is how my table looks like:
As you can see, it shows 0 for the cell where D2 has two values; but it works when there is only one value. All the rows in column D will be like cell D2, with 2 or more values, this is why it has to be dynamic using a list in the formula.
How can this be achieved in Excel? How can I make a list from the cell?
Using multiple cells would be easier! If the formula cell is one to the right of the criteria cell, you can define a named formula (Using Name Manager) called, say, GetList, which refers to this formula:
=EVALUATE("{"&INDIRECT("RC[-1]";0)&"}")
Then your formula becomes:
=SUMPRODUCT(SUMIF(A2:A11;GetList;B2:B11))
Related
Is IF(ISNUMBER(A1:A100),A1:A100,"") an array formula? If not, what is it?
I copied a list of holidays from a web site and pasted it to Excel. The original data had four columns (date, name of the holiday, weekday, note). After pasting to Excel, everything appeared in column A, like this:
date
name of the holiday
weekday
note
date
name of the holiday
.....
.....
I tried several ways to see if the data could be pasted into columns to no avail. So, I needed to extract the dates to another column. In column B, I entered this formula =IF(ISNUMBER(A1:A100),A1:A100,""). It worked to extract the dates from column A to column B.
I am not sure if it is an array formula as, unlike other array formulae, it doesn't need Ctrl-Shift-Enter. Yet, ISNUMBER usually takes a cell as the argument, not an array, and IF usually doesn't return an array.
IF and ISNUMBER are not array functions, but they can be used in array formulas.
Outside of an array formula, they accept only single input values and return single output values.
In an array formula, they can accept an array of inputs values and will return an array of outputs values.
Without pressing CTRL-SHIFT-ENTER, the formula you've specified is not an array function.
What you're seeing is the behaviour when a function that is expecting a single value is given a range and entered without pressing CTRL-SHIFT-ENTER but the input range overlaps with the row where the formula is placed.
Entering a range when a single value is expected will return the value from the range on the same row in which the formula is entered if it overlaps, otherwise it will return an error.
You are getting output only because you are placing the formula next to the rows being referenced; and it is giving the same result as if you had entered the formula normally and then filled down: i.e. putting =IF(ISNUMBER(A1),A1,"") in cell B1 and filling down.
Note that if you entered =IF(ISNUMBER(A1:A100),A1:A100,"") in cell B2 instead of cell B1 and then filled down, then the values still appear in the same row and not shifted down by a row as you might expect. Again, this is because it looks at the value in the same row just because the range overlaps with the current row.
Compare to putting =IF(ISNUMBER(A1),A1,"") in cell B2 and filling down, where you then get the values shifted down by a row as expected.
If you entered the original formula again in cell B101 (below the input range) and filled down, you get no values at all (even if there is data next to the cell) because the input range no longer overlaps the current cell. In fact, if you used the Evaluate Formula tool from the Formulas tab, you'll see that the range A1:A100 returns a #VALUE error immediately.
This behaviour is confusing and should be avoided at all costs. Only enter ranges when a function expects a range, or when an array formula is being intentionally created using CTRL-SHIFT-ENTER.
If after pasting your data to excel sheet looks like below then you can use following formula.
As shown to above screenshot user below formula to C1 cell then drag down and right as needed.
=INDIRECT("A"&(ROW()-1)*4+COLUMNS($A$1:A$1))
This formula will produce 0 (zero) for empty cells. To hide zero (0) use a IF() condition like below.
=IF(INDIRECT("A"&(ROW()-1)*4+COLUMNS($A$1:A$1))=0,"",INDIRECT("A"&(ROW()-1)*4+COLUMNS($A$1:A$1)))
I have a simple formula in cell B7 of a sheet called Summary Stats that references a sheet called Rolling Returns Data:
=COUNT('Rolling Returns Data'!C$11:C$17202)
I want to be able to dynamically reference the column in the formula i.e. I have letter C in cell B1 of the Summary Stats sheet and want to be able to replace the reference to column C in the formula with a reference to cell B1, so that if I then change the formula that calc. that is then being performed is:
=COUNT('Rolling Returns Data'!D$11:D$17202)
As Scott Craner suggested, use INDIRECT.
=COUNT(INDIRECT("'Rolling Returns Data'!"&A1&"$11:"&A1&"$17202"))
Now you just have to put the letter of the column you want to reference. You can of course change the A1 reference to anything you'd like. Or you can change the code to the following
=COUNT(INDIRECT("'Rolling Returns Data'!"&A1))
and use A1 to specify the address of your column, in this case "C$11:C$17202".
If you're ok using column numbers rather than column letters then this non-volatile formula will work:
=COUNT(INDEX('Rolling Returns Data'!1:17202,11,$B$1):INDEX('Rolling Returns Data'!1:17202,17202,$B$1))
If you really want to use column letters then you can turn a column letter into a column number using:
=COLUMN(INDIRECT($B$1 & 1))
But then you lose the non-volatile nature.
Edit:
If you use the column numbers and leave B1 blank it will return the count of all columns.
I have created a dynamic table in excel through a SUMIFS formula:
=SUMIFS(data!$D:$D,data!$B:$B,Sheet2!B$3,data!$C:$C,Sheet2!B$2,data!$A:$A,Sheet2!$A4)
this is what the table looks like:
while the data looks like:
Now I am picking values from the column Order Total. What I would like to do is to insert a dropdown list on cell B1 to dynamically select from what column I want to get the data.
Is there a way to add this in my formula?
Ok, since order total is in column D, I'll replace the first piece of the sumifs with the indirect, and I'm assuming the data is on the data worksheet, as well as cell B1 which you want the dropdown: =SUMIFS(indirect("data!$"&data!B1&":$"&data!B1),data!$B:$B,Sheet2!B$3,data!$C:$C,Sheet2!B$2,data!$A:$A,Sheet2!$A4)
What the indirect does is concatenate (using the '&' symbol) the string information with the cell information, then change it to a cell reference. If you copy everything within the indirect into another cell (preceded by "="), it would return your original data!$D:$D, if you put "D" in cell B1. This then becomes the cell references for the sumifs formula when using the indirect formula. If you change cell B1 on the Data worksheet to "E", the formula would evaluate to data!$E:$E within the indirect, which would then mean the sumifs formula references column E.
I have two excel sheets. The one that contains the data "gdsc_en_input_w2" and the other one will contain a selective number of cells from "gdsc_en_input_w2".
I am using the current formula:
=INDEX(gdsc_en_input_w2!$A$1:$YE$13848,MATCH("AKT2",gdsc_en_input_w2!$A$1:$A$13848,0),MATCH($A$3,gdsc_en_input_w2!$A$1:$YE$1,0))
I want to fill an entire column in the second sheet by referencing columns in the "gdsc_en_input_w2" sheet but based on the values stored in the column $A$1:$A$13848. As you can see the second match() matches only $A$3 ...is there a way to fill the required column with the formula with incremental column reference in the second match() function in the formula above. in other words I want to fill in the second cell of the target column the following formula :
=INDEX(gdsc_en_input_w2!$A$1:$YE$13848,MATCH("AKT2",gdsc_en_input_w2!$A$1:$A$13848,0),MATCH($A$4,gdsc_en_input_w2!$A$1:$YE$1,0))
note that the match now has $A$4 instead of $A$3.
Assuming that I am understanding what you are wanting, this formula is going to be in one column where each subsequent row will have a higher number (3,4,5,...) If that is the case, unlock your formula to read:
=INDEX(gdsc_en_input_w2!$A$1:$YE$13848,MATCH("AKT2",gdsc_en_input_w2!$A$1:$A$13848,0),MATCH($A3,gdsc_en_input_w2!$A$1:$YE$1,0)) (I removed the $ in-front of the 3)
Paste that into the whatever your starting cell is, then auto-fill
I am trying to find the formula that will search in column A (of worksheet "ABC") to find a value matching G4 in worksheet "XYZ" Once that value is found, return the value of the cell adjacent (column B of "ABC") to the cell in which this formula exists in worksheet "XYZ". All sheets are in the same workbook.
Thank you so much!
here's an example of what you're describing:
In spreadsheet ABC, you have a reference value in column A and data in column B
In spreadsheet XYZ, you have a matching number in column A. You'd like to pair the data from spreadsheet ABC to the value in XYZ:
If you notice the formula in the formula bar on the second picture, you'll see the vlookup formula to pull the data for this example. I also added an apostrophe in front of the formula in cell B1 (image 2) to have it display the formula. Note the formulas are slightly different since they point to different reference cells.
Also, here's a great reference for how the vlookup function works:
http://chandoo.org/wp/2012/03/30/comprehensive-guide-excel-vlookup/
Here is another solution that's closer to your adjusted question.
This solution still uses the vlookup formula. Instead of using it to associate a value on multiple rows, you can look-up a single value. (same function, different application)
Again, I'll point you to a great reference for how the vlookup function works:
http://chandoo.org/wp/2012/03/30/comprehensive-guide-excel-vlookup/