简体   繁体   English

Excel-查找-跨多个工作表的多个结果

[英]Excel - Lookup - Multiple result across multiple worksheets

Im doing a work calendar, that should be filled automatically depending of the day of the week or of the day of the month. 我正在做一个工作日历,该日历应根据一周中的某天或每月的某天自动填充。 Meaning: 含义:

I have weekly chores (each are equally every week) and monthly chores (each are equally for every specific work day of the month). 我有每周的家务(每个星期平均)和每月的家务(每个月每个特定工作日都一样)。

The idea is every time i change the month of the calendar, is filled with the chores needed to be done for each day. 这个想法是每次我更改日历的月份时,都会充满每天要做的琐事。

This is the calendar that i'm doing (the red cells are filled by hand, the rest is automatically filled with the formula below): Calendar 这是我正在做的日历(手动填写红色单元格,其余的自动用下面的公式填充): 日历

Week Chores sheet Sheet ToDos week 周杂务表Sheet ToDos周

Month Chores sheet Sheet ToDos Month 月杂务表Sheet ToDos Month

I already filled the weekly chores automatically with: 我已经自动填写了每周的琐事:

=IFERROR(INDEX('ToDos Week'!$C$3:$C$98;SMALL(IF((WEEKDAY($C$3;2)='ToDos Week'!$B$3:$B$98);ROW('ToDos Week'!$B$3:$B$98)-MIN(ROW('ToDos Week'!$B$3:$B$98))+1;"");ROWS($L$1:L3)));"")

Works like a charm 奇迹般有效

But my difficulty now is to add the monthly chores 但是我现在的困难是增加每月的琐事

I Tried to add 我试图添加

=IFERROR(IFERROR(INDEX('ToDos Week'!$C$3:$C$98;SMALL(IF((WEEKDAY($F$3;2)='ToDos Week'!$B$3:$B$98);ROW('ToDos Week'!$B$3:$B$98)-MIN(ROW('ToDos Week'!$B$3:$B$98))+1;"");ROWS($L$1:L1)));INDEX('ToDos Month'!$C$3:$C$91;SMALL(IF((NETWORKDAYS(F$5-DAY(F$5)+1;F$5;holidays)='ToDos Month'!$B$3:$B$91);ROW('ToDos Month'!$B$3:$B$91)-MIN(ROW('ToDos Month'!$B$3:$B$91))+1;"");ROWS($L$1:L1))));"")

of course doesn't work because the part "ROWS($L$1:L1)" of the formula will stretch and will not give me the first occurrence of the month chores (in case there's week chores in the same day), but the third or fourth.. 当然是行不通的,因为公式中的“ ROWS($ L $ 1:L1)”部分会延伸,并且不会给我第一次出现的月份琐事(以防在同一天有星期的琐事),但是第三或第四

Can you help me with this? 你能帮我吗?

{Big Edit} Okay, I've just realised I overlooked a really simple solution - as demonstrated in an earlied edit, we can use COUNTIF to get the number of Daily Tasks for the weekday. {大编辑}好的,我刚刚意识到我忽略了一个非常简单的解决方案-如早期编辑中所示,我们可以使用COUNTIF来获取工作日的每日任务数。 So, we can subtract this from the Monthly Task count to correct the number. 因此,我们可以从“每月任务”计数中减去此数字以更正此数字。

To Simplify: Is the task Weekly or Monthly? 简化:任务是每周还是每月? (You may need to add/subtract from ROWS to get it to line up) (您可能需要从ROWS添加/减去才能使其排列)

=IF(COUNTIF('ToDos Week'!$B$3:$B$98,WEEKDAY($C$3,2))>=ROWS($L$1:L3), "Weekly", "Monthly")

Use your existing code for Weekly. 使用现有的每周代码。 For Monthly, just subtract COUNTIF('ToDos Week'!$B$3:$B$98,WEEKDAY($C$3,2)) from the ROWS to remove all the Weekly tasks: 对于每月,只需从COUNTIF('ToDos Week'!$B$3:$B$98,WEEKDAY($C$3,2))减去COUNTIF('ToDos Week'!$B$3:$B$98,WEEKDAY($C$3,2))即可删除所有每周任务:

IFERROR(INDEX('ToDos Month'!$B$3:$B$98;SMALL(IF((DAY($C$3;2)='ToDos Month'!$A$3:$A$98);ROW('ToDos Month'!$A$3:$A$98)-MIN(ROW('ToDos Month'!$A$3:$A$98))+1;"");ROWS($L$1:L3)))-COUNTIF('ToDos Week'!$B$3:$B$98,WEEKDAY(C$3,2))>=ROWS($L$1:L3);"")

Replace the "Weekly" and "Monthly" in the IF above, and you get: 替换上面的IF"Weekly""Monthly" ,您将获得:

=IF(COUNTIF('ToDos Month'!$B$3:$B$98,WEEKDAY(C$3,2))>=ROWS($L$1:L3),IFERROR(INDEX('ToDos Week'!$C$3:$C$98;SMALL(IF((WEEKDAY($C$3;2)='ToDos Week'!$B$3:$B$98);ROW('ToDos Week'!$B$3:$B$98)-MIN(ROW('ToDos Week'!$B$3:$B$98))+1;"");ROWS($L$1:L3)));""),IFERROR(INDEX('ToDos Month'!$B$3:$B$98;SMALL(IF((DAY($C$3;2)='ToDos Month'!$A$3:$A$98);ROW('ToDos Month'!$A$3:$A$98)-MIN(ROW('ToDos Month'!$A$3:$A$98))+1;"");ROWS($L$1:L3)))-COUNTIF('ToDos Week'!$B$3:$B$98,WEEKDAY(C$3,2))>=ROWS($L$1:L3);""))

Old answer below 下面的旧答案


Okay, there are 2 possible solutions I can think of here... The first, and simplest, only works if your Weekly Tasks and Monthly Tasks are formatted differently (eg Monthly tasks may all start "[M]", such as "[M]File Invoices") In that case, replace the ROWS(L$1:L3) with a COUNTIF to count the Monthly tasks (eg COUNTIF(L$1:L3;"[M]*") ) 好的,我在这里有2种可能的解决方案...第一种也是最简单的解决方案,仅当您的每周任务和每月任务的格式不同时(例如,每月任务都可能以“ [M]”开头,例如“ [[ M]文件发票“)在这种情况下,用COUNTIF替换ROWS(L$1:L3)以计算每月任务(例如COUNTIF(L$1:L3;"[M]*") ))

If you have no 'easy' way to check weekly/monthly, the next option would be to use a SUM in the Array Formula to compare each entry in $L1:L3 against the ToDos Month list (eg SUM(COUNTIF('ToDos Month'!$B$3:$B$91;L$1:L3)) , taking advantage of the fact that a COUNTIF where both arguments are arrays will itself return an array) 如果您没有每周/每月检查的简单方法,那么下一个选择是在数组公式中使用SUM来比较$L1:L3中的每个条目与ToDos Month列表(例如SUM(COUNTIF('ToDos Month'!$B$3:$B$91;L$1:L3)) ,利用两个参数均为数组的COUNTIF本身将返回数组的事实)

These 2 options should give you the number of Monthly tasks in your day, for the k of your SMALL function 对于SMALL函数的k ,这2个选项应为您提供一天中每月任务的数量

{EDIT:Removing the 'blank' column} This needs redoing for each week/row. {编辑:删除“空白”列} 这需要每周/行重做。 It is based on my test sheet, where cell A14 was 05/02/2018, E14 was 09/02/2018 and the array formula was put into A15 and filled down-and-right to E23 它基于我的测试表,其中单元格A14是2018年5月2日,单元格E14是2018年2月9日,并将数组公式放到A15中,并一直向下填充到E23

=IF(COUNTIF('ToDos Week'!$B$3:$B$98,WEEKDAY(A$14,2))>=ROWS(A$14:A14),IFERROR(INDEX('ToDos Week'!$C$3:$C$98,SMALL(IF((WEEKDAY(A$14,2)='ToDos Week'!$B$3:$B$98),ROW('ToDos Week'!$B$3:$B$98)-MIN(ROW('ToDos Week'!$B$3:$B$98))+1,""),ROWS(A$14:A14))),""),IFERROR(INDEX('ToDos Month'!$B$3:$B$98,SMALL(IF((DAY(A$14)='ToDos Month'!$A$3:$A$98),ROW('ToDos Month'!$A$3:$A$98)-MIN(ROW('ToDos Month'!$A$3:$A$98))+1,""),COUNTIF(A$14:A14,"Month*")+1)),""))

First thing it does it check how many Weekly tasks there are for the day. 首先,它会检查当天有多少个每周任务。 If this is greater than the number of tasks already filled out, it looks for a Weekly task, otherwise it looks to a Monthly task - counting the existing Monthly tasks as starting with "Month" 如果该数目大于已完成的任务数,则查找“每周”任务,否则查找“每月”任务-将现有的“每月”任务计数为以“月”开头

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

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