在excel中列出星期五和星期六

dfty9e19  于 2023-03-31  发布在  其他
关注(0)|答案(2)|浏览(179)

使用excel公式,在单元格K6中有一个日期2023-03-01,在单元格E11中,我为星期五输入了以下公式

=IF(MONTH($K$6-MOD(WEEKDAY($K$6,1)-6,7)+IF(WEEKDAY($K$6,1)<6,7,0)+7*(INT((ROW()-11)/2)))=MONTH($K$6),$K$6-MOD(WEEKDAY($K$6,1)-6,7)+IF(WEEKDAY($K$6,1)<6,7,0)+7*(INT((ROW()-11)/2)),"")

在单元格E12中,我为星期六写了下面的公式

=IF(MONTH($K$6-MOD(WEEKDAY($K$6,1)-7,7)+IF(WEEKDAY($K$6,1)<7,7,0)+7*(INT((ROW()-11)/2)))=MONTH($K$6),$K$6-MOD(WEEKDAY($K$6,1)-7,7)+IF(WEEKDAY($K$6,1)<7,7,0)+7*(INT((ROW()-11)/2)),"")

对于K6 2023-03-01单元格中的日期,公式也是有效的
但是,当我在单元格K6中更改日期并将其变为2023-04-01时,我在E11中得到了一个空的返回,因为该月是从星期六2023-04-01开始的。是否可以使公式灵活,以便不在单元格E12或E12中得到空结果?
我可以调整E11中的公式,使其适用于星期五和星期六

=IF(MONTH($K$6-MOD(WEEKDAY($K$6,1)-6-IF(WEEKDAY(DATE(YEAR($K$6),MONTH($K$6),1),1)=7,1,0),7)+IF(WEEKDAY($K$6,1)<6,7,0)+7*(INT((ROW()-11)/2)))=MONTH($K$6),$K$6-MOD(WEEKDAY($K$6,1)-6-IF(WEEKDAY(DATE(YEAR($K$6),MONTH($K$6),1),1)=7,1,0),7)+IF(WEEKDAY($K$6,1)<6,7,0)+7*(INT((ROW()-11)/2)),"")

但是对于单元E12不进行调整。
这是我在E12牢房的尝试

=IFERROR(IF(MONTH($K$6-MOD(WEEKDAY($K$6,1)-IF(ISNUMBER(E11),7,6)-IF(WEEKDAY(DATE(YEAR($K$6),MONTH($K$6),1),1)=7,1,0),7)+IF(WEEKDAY($K$6,1)<IF(ISNUMBER(E11),7,6),IF(ISNUMBER(E11),7,6)+1,IF(ISNUMBER(E11),7,6))+7*(INT((ROW()-11)/2)))=MONTH($K$6),$K$6-MOD(WEEKDAY($K$6,1)-IF(ISNUMBER(E11),7,6)-IF(WEEKDAY(DATE(YEAR($K$6),MONTH($K$6),1),1)=7,1,0),7)+IF(WEEKDAY($K$6,1)<IF(ISNUMBER(E11),7,6),IF(ISNUMBER(E11),7,6)+1,IF(ISNUMBER(E11),7,6))+7*(INT((ROW()-11)/2)),""),"")

但结果不准确。

8cdiaqws

8cdiaqws1#

如果你有Excel 365,试试这个:

=TEXT(FILTER(SEQUENCE(DAY(EOMONTH(A4,0)),,EOMONTH(A4,-1)+1,1),WEEKDAY(SEQUENCE (DAY(EOMONTH(A4,0)),,EOMONTH(A4,-1)+1,1),1)>=6),"dd/mm/yyyy")

较短版本:

=LET(alldates,SEQUENCE(DAY(EOMONTH(A4,0)),,EOMONTH(A4,-1)+1,1),TEXT(FILTER(alldates,WEEKDAY(alldates,1)>=6),"dd/mm/yyyy"))

感谢@Jvdv

=LET(x,SEQUENCE(33,,EOMONTH(A4,-1)),FILTER(x,(MONTH(A4)=MONTH(x))*(WEEKDAY(x)>5)))
vpfxa7rd

vpfxa7rd2#

远离Excel 365这是单元格E11中的解决方案

=IF(MONTH($K$6-MOD(WEEKDAY($K$6,1)-6-IF(WEEKDAY(DATE(YEAR($K$6),MONTH($K$6),1),1)=7,1,0),7)+IF(WEEKDAY($K$6,1)<6,7,0)+7*(INT((ROW()-11)/2)))=MONTH($K$6),$K$6-MOD(WEEKDAY($K$6,1)-6-IF(WEEKDAY(DATE(YEAR($K$6),MONTH($K$6),1),1)=7,1,0),7)+IF(WEEKDAY($K$6,1)<6,7,0)+7*(INT((ROW()-11)/2)),"")

在E12牢房

=IFERROR(IF(MONTH(IF(WEEKDAY(E11)=6,E11+1,IF(WEEKDAY(E11)=7,E11+6,"")))>MONTH($K$6),"",IF(WEEKDAY(E11)=6,E11+1,IF(WEEKDAY(E11)=7,E11+6,""))),"")

相关问题