I have a pile of data on Sheet1
I have a SUMIFS formula on Sheet2
The columns I am summing are named NETPERD1, NETPERD2, NETPERD3.....NETPERD12
I want to write the SUMIFS so that I can easily change which column I am summing.
On Sheet2, in cell $C$4, I will enter NETPERD1 or NETPERD2 etc. and I want my SUMIF to determine which column it should sum.
I think I should be able to do this with IndexMatch but I can't get it to work.
Here is my SUMIFS that works.
I want to replace NETPERD1 with $C$4
=SUMIFS(Sheet1!NETPERD1,Sheet1!ACCTGRPCOD,Perplas!$A15,Sheet1!AUDTORG,Perplas!C$1,Sheet1!FSCSDSG,Perplas!C$2,Sheet1!FSCSYR,Perplas!C$3)
If your named ranges span the entire column, then for the INDEX/MATCH try:
=SUMIFS(INDEX(Sheet1!$A:$Z,,Match(Perplas!C$4,Sheet1!A$1:Z$1,0)),...
changing the Z to your rightmost column.
Try using the indirect function. You can supply indirect with a character string that Excel then reads as part of a cell/range reference.
Working off the code you shared + the fact that you said that you'll put in the name of the range in cell C4:
=SUMIFS(INDIRECT("Sheet1!"&$C$4),Sheet1!ACCTGRPCOD,Perplas!$A15,Sheet1!AUDTORG,Perplas!C$1,Sheet1!FSCSDSG,Perplas!C$2,Sheet1!FSCSYR,Perplas!C$3)
I think that should work? I'm a little confused about how you're able to reference the row name without a named range, so that might cause a wrinkle in this.
Related
This phrase is embedded in many formulas on my sheet:
OFFSET(Table1[ReportDate],0,$B$1)
It returns a reference to a column in Table1.
To make those many formulas shorter, I'd like to extract this OFFSET formula to a separate cell for the others to refer to.
The OFFSET returns a reference. Putting OFFSET(…) in a cell just returns #VALUE, and so does INDIRECT(OFFSET(…)).
EDIT: The "many formulas" are SUMIFS, and the OFFSET chooses the column to be summed:
=SUMIFS(OFFSET(Table1[ReportDate],0,$B$1),Table1[ColumnB],$H10,Table1[Report Date],"<="&rYesterday)
If I understand you correctly, you want to replace the original OFFSET formula with something simpler to be used in other formulas.
You can do so by giving a name to this OFFSET formula.
In the above mock-up example, I have given a name SUM_Rng for the OFFSET formula and used it in my second formula, which is the same as your original SUMIFS formula.
You can press Ctrl+F3 to bring out the Name Manager in Excel and add or modify names which can represent a reference of a cell or a range either hard-coded or returned by a formula. I noticed that you already used a name rYesterday in your SUMIFS formula so there should be no problem for you to add this formula to the name manager.
Cheers :)
It's probably a simple problem, but I did not even know the keywords to google it ;/. Let's say I have this data :
Now I also have this litle formula:
If I know drag the C cell to the right, Excel will attempt the following caluclation:
=2+B1
What I want him to do is to attempt this calculation
=2+A2
Of course the easiest solution would be to store my initial data in one row instead of 1 column, but it is really inconvenient for me. Thanks for any help
You can use the indirect() method to reference a cell by it's "String identifier", i.e. "A3". When filling out to the right, use CONCATENATE() and COLUMN() to create your String identifiers {A1,A2,A3,A4,A5...} as required:
=2+INDIRECT(CONCATENATE("A";COLUMN()-2))
This will result in the following:
Side-Node: If you want this for some x/y-Grid-Generation, you can also be lazy,
and just insert =COLUMN() for every cell from "A1 - Z1" and ROW() for every cell from "A2 - A24".
(Or even avoid these at all and directly perform your actual calculation by using column() and row() as replacement for your x/y.
You may try using a combination of the INDIRECT and COLUMN functions:
=2+INDIRECT("A"&(COLUMN()-2))
You would paste the above formula into cell C1, and then drag across to the right however many columns/rows you wanted to cover.
This would result in the following:
This works because COLUMN()-2 returns 1 for the C column, 2 for the D column, and so on. Therefore, the formula will be calling INDIRECT on A1, A2, etc. for column C, D, and so on.
In general, if you want relative references to move down as cells are dragged to the right, you can use this:
Instead of:
= 2+A1
Do:
= 2+INDEX($A:$A,COLUMN()+<offset>)
Where <offset> is whatever offset you need. The offset will change depending on which column the starting formula is located in.
INDEX should be preferred over INDIRECT because INDIRECT is volatile (must recalculate after any change to the workbook) but INDEX is not (only recalculated when one of the inputs the formula, in this case $A:$A, changes).
I have a straightforward formula in Excel 2010 as follows:
=VLOOKUP(D597,'Sheet1'!$AA$3:$AC$5000,3,FALSE)
The problem is the lookup_range, D597 in this case, contains a formula, not text or numbers (it is actually a reference to another sheet and cell).
The lookup is returning #N/A . I know the value is in the named range, column aa, and the value I want in column 3.
Is there a way to use vlookup, or another function, to accomplish this fairly straightforward lookup?
With help from a friend, Master Joe, I was able to pull the value underlying D597 in the above vlookup formula. The solution:
VLOOKUP(VALUE(TRIM(D597)),'Sheet1'!$AA$3:$AC$5000,3,FALSE)
I have the names of the tabs/worksheets (M-61,M-62,M-63W) at the top row (A1, B1, C1...etc)
I am trying to get a sum of several cells within the different sheets:
=SUM('M-60'!H21,'M-60'!H43,'M-60'!H86,'M-60'!H87,'M-60'!H97,'M-60'!H98)
However, right now I’m referring to the sheet itself, and have to apply the same formula to all the other sheets. This will require me to manually go and change all the sheet titles accordingly.
I was wondering if there is any way to reference the top row with the sheet titles within the formula so it automatically refers to the row text instead of me having to manually change the sheet title.
Edit
Now i got the reference to work, just wondering how would I do a sum of several cells in that tab
=INDIRECT("'"&$F1&"'!H87",TRUE)
Maybe:
=SUM(INDIRECT("'"&C1&"'!H21"),INDIRECT("'"&C1&"'!H43"),INDIRECT("'"&C1&"'!H86:H87"),INDIRECT("'"&C1&"'!H97:H98"))
(though there may well be a much smarter way).
You can use the INDIRECT function, which uses a string as an argument and converts it to a range. So
=M-60'!H21
is the same as
=INDIRECT("M-60'!H21")
or, if Sheet name is stored in, say, cell C1:
=INDIRECT(C1&"'!H21")
Your example has a SUM, though, which requires some adaptations. This your example:
=SUM('M-60'!H21,'M-60'!H43,'M-60'!H86,'M-60'!H87,'M-60'!H97,'M-60'!H98)
Since you are not using a range, you can convert that SUM into simple addition. Assuming Sheet name in cell C1
=INDIRECT("'"&C1&"'!H21")+INDIRECT("'"&C1&"'!H43")+INDIRECT("'"&C1&"'!H86")+INDIRECT("'"&C1&"'!H87")+INDIRECT("'"&C1&"'!H97")+INDIRECT("'"&C1&"'!H98")
This should solve your problem. More info here
By the way, if you were using a range, the OFFSET function with INDIRECT as an argument would work. But that's not necessary here.
=IFERROR(IF((INDEX(named range1,MATCH(named range2&A1,named range3,0)))<>"",INDEX(named range1,MATCH(named range2&A1,named range3,0)),"-"),"")
Here in this formula I am trying to vertical lookup a value using index-match and checking it within a if statement for blank value.If it is not blank I am using the non-blank value to set it in a given cell.
How can I optimise my formula to reduce performance overhead in excel.
I don't want to use vba for this by storing the result in a variable
The most time consuming bit is the Match(), so avoiding a duplication of the same Match is key. You can
place the Index/Match in a helper cell and then use the formula
=IFERROR(IF(B1<>"",B1,"-"),"")
This way the Index/Match will be calculated only once.
place the Match into a named formula. If you keep your wits about you, named formulas can work with relative cell references. Select the cell where you want the formula to go, then create a named range "NamedRange4" with the formula
=MATCH(named range2&A1,named range3,0)
Then use this formula in the selected cell:
=IFERROR(IF((INDEX(named range1,NamedRange4))<>"",INDEX(named range1,NamedRange4),"-"),"")
The Match will be calculated only once and the result stored in the named range. With relative cell referencing of NamedRange4, the IfError formula can be used in other cells with correct results.