简体   繁体   English

Excel。 Weeknum函数。 #值! 错误。 日历

[英]Excel. Weeknum function. #VALUE! error. Calendar

值错误

Dear person. 亲爱的人 As you can see in the picture there is a #VALUE! 如您在图片中看到的,有一个#VALUE! error when it tries to show some weeknumbers. 尝试显示一些星期数时出错。

Referring to the picture: 参考图片:

Nr. Nr。 1. I'm trying to figure out how to show the weeknumbers that have datenumbers in that week 1.我试图弄清楚如何显示该周中有日期数字的星期数字

Nr. Nr。 2. I'm trying to figure out how to show a blank cell for the rows with no datenumbers in that week 2.我试图弄清楚如何显示那周没有日期数字的行的空白单元格

The workbook: https://www.dropbox.com/s/ed6dt022i0yz6py/Calendar.xlsx?dl=0 工作簿: https : //www.dropbox.com/s/ed6dt022i0yz6py/Calendar.xlsx?dl=0

Help!:) 救命!:)

I think this is the one you want based on weeks from Monday to Sunday 我认为这是您想要的,从周一到周的几周

=IFERROR(WEEKNUM(AGGREGATE(15,0,C17:I17,1),2),"")

I have chosen to use Aggregate because it will error out if there are no numbers in the range, so IFERROR will give a blank. 我选择使用Aggregate,因为如果范围内没有数字,它将出错,因此IFERROR将给出一个空白。 You could just use MIN or MAX instead and test for the result being zero. 您可以只使用MIN或MAX并测试结果是否为零。 You could also use LOOKUP or HLOOKUP. 您也可以使用LOOKUP或HLOOKUP。 This might be the shortest way 这可能是最短的方法

=IFERROR(WEEKNUM(LOOKUP(99999,C17:I17),2),"")

The week starting with December 31st ('week 53') is really week 1 of 2019 so you could add a separate condition for this. 从12月31日开始的一周(“第53周”)实际上是2019年的第1周,因此您可以为此添加单独的条件。

在此处输入图片说明

To fix the 'week 53' issue, I can't do any better than this rather long formula at present 要解决“第53周”问题,我现在做不到比这个相当长的公式更好的了

=IF(COUNT(C17:I17)=0,"",IF(AND(MONTH(LOOKUP(9E+99,C17:I17))=12,C17<>"",I17=""),1,WEEKNUM(LOOKUP(9E+99,C17:I17),2)))

which says 'if it is the last week of December and at least one of the days in that week is empty, then the week is week one of the following year'. 表示“如果是12月的最后一周,并且该周中至少有一天是空的,则该周是次年的第一周”。

This could be further modified to deal with an ISO year where week 1 is the first week containing a Thursday. 可以对其进行进一步修改,以处理ISO年,其中第1周是包含星期四的第一周。

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

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