简体   繁体   中英

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.

在此处输入图片说明

please note that L:19 to L:24 has a drop down list of type of transport as listed below. Each trip number (1 to 4) has to have its own time added ( D:48 to D: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. In this column you would use a vlookup to your table of "Means of Transportation". So if your lookup table is on sheet2 in A1:B11 then in P19 on your user form put

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

And copy down.

Then in D48 use A simple SumIf() function:

=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. Then copy down.

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