简体   繁体   中英

How do I populate a table based on a drop-down list?

I'm trying to make a spreadsheet for a personal project that involves a set of drop down menus, whose contents correspond to the contents of a reference table.

Each row in the main table has two associated drop-down menus, and populates the row with the the element-wise product of both of the related sets. For example: If the first row the table were set to "Fire" and "Water", the first three elements in the list would be 1*1, 0.5*0.5, and 2*0.5.

The element-wise multiplication I understand how to do. What I can't figure out how to do (and I've spent several hours searching) is how to reference those values based on the drop-down list. I thought I had figured out a way to do it by using referencing named ranges with INDIRECT(), but it doesn't seem to work. I've spent a good few hours trying to figure this out as well as researching drop-down lists, but I couldn't find anything. Any help would be appreciated.

Screenshots of the sheets in question are here .

Try putting this formula starting in Sheet1!C3 :-

=INDEX(Sheet2!$C$2:$T$20,MATCH($A3,Sheet2!$B$2:$B$20,0),COLUMN(A:A))*
INDEX(Sheet2!$C$2:$T$20,MATCH($B3,Sheet2!$B$2:$B$20,0),COLUMN(A:A))

The idea is that it gets the row in the 2D range Sheet2!C2:T20 by matching A3 or B3 against the labels in sheet2!B2:B20, then gets the column using the COLUMN function to get COLUMN(A:A) which is equal to 1 so INDEX(RANGE,ROW,COLUMN) gives you the first pair of values. Then when the formula is pulled across COLUMN(A:A) changes to COLUMN(B:B) and you get the second pair of values and so on.

Tested in Excel: for Open Office, change , to ; and ! to . also A:A to A1

=INDEX(Sheet2.$C$2:$T$20;MATCH($A3;Sheet2.$B$2:$B$20;0);COLUMN(A1))* 
INDEX(Sheet2.$C$2:$T$20;MATCH($B3;Sheet2.$B$2:$B$20;0);COLUMN(A1))

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM