Overview:I am trying to use INDIRECT combined with INDEX, ROW and COLUMN to get a dynamic table working.
Problem:
How I'm doing it (Wrong, apparently):
{=MAX(IF('Worksheet 2'!$A$4:$A$101=INDIRECT(ADDRESS(ROW();COLUMN()-1;4)); 'Worksheet 2'!$D$4:$D$101))}
What I would expect it to do:
INDIRECT(ADDRESS(ROW();COLUMN()-1;4))
--- Read content to the cell on the left in Worksheet 1
'Worksheet 2'!$A$4:$A$101=INDIRECT(ADDRESS(ROW();COLUMN()-1;4))
--- Get an array of TRUE/FALSE values, where TRUE is found where Worksheet 2 column A contains the value previousl
IF('Worksheet 2'!$A$4:$A$101=INDIRECT(ADDRESS(ROW();COLUMN()-1;4)); 'Worksheet 2'!$D$4:$D$101)
--- For each TRUE, extract the corresponding value from COLUMN D of Worksheet 2
{=MAX(IF('Worksheet 2'!$A$4:$A$101=INDIRECT(ADDRESS(ROW();COLUMN()-1;4)); 'Worksheet 2'!$D$4:$D$101))}
--- From the COLUMN D extracted values, take the MAX
What I get: A #VALUE! Error.
Can somebody explain me why and propose a feasible substitution?
It's because your INDIRECT
cell reference is part of an array formula, so you get {"A1"}
instead of "A1"
, for example.
This can be resolved by using MAX
, e.g.:
{=MAX(IF('Worksheet 2'!$A$4:$A$101=MAX(INDIRECT(ADDRESS(ROW();COLUMN()-1;4))); 'Worksheet 2'!$D$4:$D$101))}
(It looks like you also had a few brackets out of place.)
Update:
This is a better version which will work for your text columns (use MAX
on the ROW
and COLUMN
functions):
=MAX(IF('Worksheet 2'!$A$4:$A$101=INDIRECT(ADDRESS(MAX(ROW());MAX(COLUMN())-1;4)); 'Worksheet 2'!$D$4:$D$101))