简体   繁体   English

如何根据下拉列表填充表格?

[英]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. 例如:如果表的第一行设置为“火”和“水”,则列表中的前三个元素将为1 * 1、0.5 * 0.5和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. 我以为自己想出了一种方法,可以使用INDIRECT()引用命名范围,但这似乎不起作用。 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 :- 尝试将此公式从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. 这个想法是通过将A3或B3与sheet2!B2:B20中的标签匹配来获取2D范围Sheet2!C2:T20中的行,然后使用COLUMN函数获取列以获取COLUMN(A:A)等于1,所以INDEX(RANGE,ROW,COLUMN)为您提供第一对值。 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. 然后,当公式跨过COLUMN(A:A)变为COLUMN(B:B)时,您将获得第二对值,依此类推。

Tested in Excel: for Open Office, change , to ; 经测试,在Excel中:对开放式办公,变化,; and ! to . also A:A to A1 也是A:A到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))

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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