I want to do the following:
- Take a sheet name
- Search a range on that sheet (same range on each sheet) for a given value
- Get a value on that sheet, in the found row, from a certain column
Steps 2 and 3 alone are straightforward (at least, in that I figured out the process by a combination of the docs and a Q&A here on Ask LibreOffice):
=INDIRECT(ADDRESS(MATCH($A1,Foo.$A1:$A10,0),3,1,1,"Foo"))
(In this example, the search key for MATCH
is in column A, both on this sheet and on sheet "Foo"
. The value sought is in column C, hence the column argument is 3.)
But not hard-coding the sheet name "Foo"
is proving challenging, because the ADDRESS
function only returns a single cell, not a range like Foo.$A1:$A10
.
My best work-around is this ugly thing:
=INDIRECT(ADDRESS(MATCH($A1,INDIRECT(ADDRESS(1,1,1,1,$B1)&":"&ADDRESS(10,1,1,1,$B1)),0),3,1,1,$B1))
(Now, the sheet name to search is in column B.)
Is there a better way to do it?