简体   繁体   English

用户表单的复杂公式(2)

[英]Complicated formula for a user form (2)

I am working on a user form where I need to find a way to add a certain amount of "additional hours" ( D:48 to D:51 ) based on the "means of transport" ( L:19 to L:24 ) selected by the user. 我正在处理一个用户表单,需要根据“运输方式”( L:19 to L:24 )找到一种方法来添加一定量的“额外时间”( D:48 to D:51 )由用户选择。

在此处输入图片说明

please note that L:19 to L:24 has a drop down list of type of transport as listed below. 请注意, L:19L:24的交通类型下拉列表如下所示。 Each trip number (1 to 4) has to have its own time added ( D:48 to D:51 ). 每个行程编号(1至4)必须添加自己的时间( D:48D:51 )。 The amount of time to be added per "means of transport" type is as follows: 每种“运输方式”类型要增加的时间如下:

在此处输入图片说明

Many thanks in advance Abe 提前非常感谢安倍

The easiest way is to put a helper column in P, this can be hidden. 最简单的方法是在P中放置一个辅助列,这可以隐藏。 In this column you would use a vlookup to your table of "Means of Transportation". 在此列中,您将对“运输工具”表使用vlookup。 So if your lookup table is on sheet2 in A1:B11 then in P19 on your user form put 因此,如果您的查找表在A1:B11中的sheet2上,则在用户表单上的P19中

=VLOOKUP(L19,'Sheet2'!$A$1:$B$11,2,False)

And copy down. 并抄下来。

Then in D48 use A simple SumIf() function: 然后在D48中使用一个简单的SumIf()函数:

=SUMIF($A$19:$A$24,A48,$P$19:$P$24)

And copy down 然后抄下来

This should give you the results you are looking for. 这应该为您提供所需的结果。

Or If you want one formula to do it all then use the following Array Formula: 或者,如果您希望一个公式完成所有操作,请使用以下数组公式:

=SUMPRODUCT(SUMIFS('Sheet2'!$B$1:$B$11,'Sheet2'!$A$1:$A$11,$L$19:$L$24)*($A$19:$A$24=A48))

Put in D48, Hit Ctrl-Shift-Enter. 放入D48,按Ctrl-Shift-Enter。 Then copy down. 然后抄下来。

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

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