简体   繁体   English

使用 MOD function 全年 21 天开启和 7 天关闭轮换

[英]21 days ON & 7 days OFF rotation through out the year using MOD function

I'm using IF + MOD function to return 1 or 0, it is supposed to be 21 cells with 1 followed by 7 cells with 0 but the result is not as expected.我正在使用 IF + MOD function 返回 1 或 0,它应该是 21 个单元格和 1,然后是 7 个单元格和 0,但结果不符合预期。 A1 has 21 then A2 has 7 to simulate the 21/7 days rotation. A1 有 21 然后 A2 有 7 来模拟 21/7 天轮换。 I put this formula =IF(MOD(ROW(A21),$A$1+$A$2)>=$A$2,1,0) to B1 and dragged down, the result is 7 consecutive cells of 1 followed by 7 cells with 0, 21 with 1 then 7 with 0. The rest are constant cycle of 21 and 7. What am I missing on this formula and what are the limitations if I need to use this on rows rather than columns or in multiple rows/ columns?我把这个公式 =IF(MOD(ROW(A21),$A$1+$A$2)>=$A$2,1,0) 放到 B1 并往下拉,结果是 7 个连续的单元格 1 后跟 7 个单元格0、21 和 1 然后 7 和 0。rest 是 21 和 7 的恒定循环。我在这个公式中遗漏了什么,如果我需要在行而不是列或多行/列中使用它,有什么限制?

You could modify your formula like that:你可以像这样修改你的公式:

=IF(MOD(ROW(A1)-1,$A$1+$A$2)>=$A$1,0,1)

then it print correctly a series of 21 times 1 and 7 times 0 in loop然后它在循环中正确打印一系列 21 次 1 和 7 次 0

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

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