How to work Excel INDIRECT and INDEX functions
I'm not sure what the INDEX function does, but I know INDIRECT summons data from another sheet.
I'll try to you explain my formula.
This formula (with nested
INDIRECT function) return SUM first values from respective range on the Sheet HQ
=SUMIF(INDIRECT($B3&"!$B2:B"&$C3+1,TRUE),">0",HQ!B$2:B$22)
If you look '
Evaluate formula' then you can see the calculation formula step by step.
SUMIF function has the syntax
=SUMIF(range,criteria,sum_range)
INDIRECT function has the syntax
You can omit the second argument, "a1" ie. 'TRUE' if you want to
Example:
If you putting it in cell A1 of data B3 (ie. address B3 of the cell in the worksheet "base templates"), =INDIRECT(A1)
formula will return as a result value or text in cell B3 and this is finally the text 'HQ'
Thus the above mentioned first formula works as follows
If you click the "formula bar 'or press 'F2' you can select the argument (function) and
press 'F9' key.
Excel will automatically calculate the result of the respective highlighted function/formula. (See end of this tutorial "
Nested function")
So if you highlight a function INDIRECT (argument "range" inside SUMIF function) and
press F9 key Excel return next result
by press F9
INDIRECT($B3&"!$B2:B"&$C3+1,TRUE)
will be result
{100,180,324,584}
The result is the first four values of the sheet ranges from HQ!$B2:B5
'Criteria' is second argument from SUMIF function, This is equivalent to our condition ">0" greater than zero
The last argument of SUMIF function is 'sum_range' and that is the equivalent of 'HQ!B$2:B$22'.
If you again highlight the last argument inside SUMIF function and you
press F9 Excel will return as follows.
{100,180,324,584,1052,2104,4208,7574,16832,27773,34085,56808,93733,115036,191727,316350,388248,647081,1067684,1310340,2183900}
Finally Excel will compare the first and last argument for SUMIF function (of course using the criterion) and sum up values that match.
Then our SUMIF formula looks like this
=SUMIF({100,180,324,584},">0",{100,180,324,584,1052,2104,4208,7574,16832,27773,34085,56808,93733,115036,191727,316350,388248,647081,1067684,1310340,2183900})
So, you could notice if you look '
Evaluate formula' nested INDIRECT function return a range of cells, depending on the title sheet in the B3 and level value in C3.
INDIRECT($B3&"!$B2:B"&$C3+1) return to HQ!$B2:B5
When you copy formula down, this data will be changed.
As for the
INDEX function, its syntax is
=INDEX(array,row_num,column_num)
Example:
Therefore, the formula will return as a result the data or the information from intersection of the third row of the second column in a respective range.
With this INDEX function is often used
MATCH function (as second argument 'row_num') that returns a number of row. You could also use the COLUMN function as the third argument.
I hope that I have succeeded to some extent explain (of course with the link that gave colleague @pecoflyer)