excelarray-formulasexcel-indirect

How do I use INDIRECT inside an Excel array formula?


The situation

The problem

The following formula returns all the correct references to hours booked on "Foo", so far so good.

=IF(Planning!$D$11:$CV$18="Foo";ADDRESS(ROW(Planning!$D$11:$CV$18);COLUMN(Planning!$D$11:$CV$18)+1;;;"Planning"))

{"Planning!$E$11"\FALSE\FALSE\FALSE\FALSE\"Planning!$J$12"}

However, if I use the INDIRECT function to retrieve the values of those references, they always return the value of the first reference in the array ("Planning!$E$11")

=IF(Planning!$D$11:$CV$18="Foo";INDIRECT(ADDRESS(ROW(Planning!$D$11:$CV$18);COLUMN(Planning!$D$11:$CV$18)+1;;;"Planning")))

{8\FALSE\FALSE\FALSE\FALSE\8}

How do I retrieve the correct values? Or should I tackle the problem in a whole different way?

Screenshots


Solution

  • Since I was mainly interested in the total of planned hours, I eventually used the following formula:

    =SUM(SUM(INDIRECT(IF(Planning!$D$11:$CV$18="Foo";(ADDRESS(ROW(Planning!$D$11:$CV$18);COLUMN(Planning!$D$11:$CV$18)+1;;;"Planning"));"$U$19"))))

    1. IF: Create the array with references to the Planning sheet if the string is found. If it's not found, add the reference $U$19.
    2. Using INDIRECT, replace all references with the values in the Planning sheet. $U$19 contains the value 0.
    3. Then use SUM twice to sum up all the values. I don't know why, but see