[英]Pulling information from 1 worksheet to another, based on drop down list selection
I am trying to get a spreadsheet to auto populate rates for products, based on the size of the order, which are chosen from a drop-down menu. 我正在尝试获取一个电子表格,以根据订单的大小自动填充产品的费率,该数量是从下拉菜单中选择的。
I am using 2 workseets - Sheet 1 has a data validation drop down list of the Order Sizes (0-49, 50-99, 100+), and another column of Products, where I would like the rates to come across. 我正在使用2名工作人员-工作表1的数据验证下拉列表为订单大小(0-49、50-99、100 +),以及“产品”的另一列,我希望能看到这些价格。 Sheet 2 has 3 tables - One table per Order Size, containing the products' rates for that size order (Table 1 = 0-49, Table 2 = 50-99, Table 3 = 100+).
工作表2有3张表-每个订单大小一张表,其中包含该大小订单的产品费率(表1 = 0-49,表2 = 50-99,表3 = 100+)。
I can't figure out how to get the rates from the 3 tables (on Sheet 2) to pull across and auto-populate in the Products column (on Sheet 1), once I've chosen the Order Size from the drop down list (on Sheet 1). 从下拉列表中选择订单大小后,我无法弄清楚如何从3个表格(第2页)中获取费率,以便在“产品”列(第1页)中进行查询并自动填充(在工作表1上)。
I hope that makes sense. 我希望这是有道理的。 Unfortunately I'm too new to this site, so it won't let me post images or files
不幸的是,我对这个网站太陌生,所以它不会让我发布图像或文件
I don't really understand Macros or VBA, so please dumb it down for me :-) Thank you! 我不太了解Macros或VBA,所以请帮我弄个傻瓜:-)谢谢!
You can accomplish this without using any VBA by making use of the IF and VLOOKUP functions. 您可以通过使用IF和VLOOKUP函数而无需使用任何VBA来完成此操作。 I'm assuming your data looks like this:
我假设您的数据如下所示:
The formula in B8 is: B8中的公式是:
=IF(B2="0-49",VLOOKUP(B5,Sheet2!A3:B5,2,FALSE),IF(B2="50-99",VLOOKUP(B5,Sheet2!A8:B10,2,FALSE),IF(B2="100+",VLOOKUP(B5,Sheet2!A13:B15,2,FALSE),"Enter a valid order size selection")))
Basically the IF statements tell it which table to look in, based on the selected order size, and the VLOOKUP statements do the looking up based on the selected product. 基本上,IF语句根据选定的订单大小告诉它要查找哪个表,而VLOOKUP语句根据选定的产品进行查找。 An IF statement takes the form of:
IF语句的形式为:
IF(logical_test, [value_if_true], [value_if_false])
So, this first checks if the value of B2 is "0-49." 因此,这首先检查B2的值是否为“ 0-49”。 If it is, it performs the lookup in the small order table.
如果是这样,它将在小订单表中执行查找。 If it's not, it goes on to check if the value is "50-99."
如果不是,则继续检查该值是否为“ 50-99”。 Etc. Then, at the end, if the value isn't any of the options, it prompts the user to enter a valid order size.
等等,最后,如果该值不是任何选项,它将提示用户输入有效的订单大小。
See: 看到:
http://office.microsoft.com/en-us/excel-help/if-function-HP010342586.aspx http://office.microsoft.com/zh-cn/excel-help/if-function-HP010342586.aspx
http://office.microsoft.com/en-us/excel-help/vlookup-HP005209335.aspx http://office.microsoft.com/zh-cn/excel-help/vlookup-HP005209335.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.