if函数太多,想请教大神类似这种公式没有什么办法替代也优化的
目的是根据日期锁定求和范围,如:如果E3=9月20日,则求生产汇总表中8月26日至9月25日的和;如果E3=8月20日,则求生产汇总表中7月26日至8月25日的和;以此类推
=IF(AND($E$3>=DATE(2024,7,26),$E$3<=DATE(2024,8,25)),SUMIFS(生产汇总表!L:L,生产汇总表!$B:$B,">=2024-7-26",生产汇总表!$B:$B,"<=2024-08-25",生产汇总表!B:B,"<="&$E$3,生产汇总表!B:B,"<="&$E$3,生产汇总表!C:C,L2),IF(AND($E$3>=DATE(2024,8,26),$E$3<=DATE(2024,9,25)),SUMIFS(生产汇总表!L:L,生产汇总表!$B:$B,">=2024-8-26",生产汇总表!$B:$B,"<=2024-09-25",生产汇总表!B:B,"<="&$E$3,生产汇总表!B:B,"<="&$E$3,生产汇总表!C:C,L2),IF(AND($E$3>=DATE(2024,9,26),$E$3<=DATE(2024,10,25)),SUMIFS(生产汇总表!L:L,生产汇总表!$B:$B,">=2024-9-26",生产汇总表!$B:$B,"<=2024-10-25",生产汇总表!B:B,"<="&$E$3,生产汇总表!B:B,"<="&$E$3,生产汇总表!C:C,L2),IF(AND($E$3>=DATE(2024,10,26),$E$3<=DATE(2024,11,25)),SUMIFS(生产汇总表!L:L,生产汇总表!$B:$B,">=2024-10-26",生产汇总表!$B:$B,"<=2024-11-25",生产汇总表!B:B,"<="&$E$3,生产汇总表!B:B,"<="&$E$3,生产汇总表!C:C,L2),IF(AND($E$3>=DATE(2024,11,26),$E$3<=DATE(2024,12,25)),SUMIFS(生产汇总表!L:L,生产汇总表!$B:$B,">=2024-11-26",生产汇总表!$B:$B,"<=2024-12-25",生产汇总表!B:B,"<="&$E$3,生产汇总表!B:B,"<="&$E$3,生产汇总表!C:C,L2),IF(AND($E$3>=DATE(2024,6,26),$E$3<=DATE(2024,7,25)),SUMIFS(生产汇总表!L:L,生产汇总表!$B:$B,">=2024-6-26",生产汇总表!$B:$B,"<=2024-7-25",生产汇总表!B:B,"<="&$E$3,生产汇总表!B:B,"<="&$E$3,生产汇总表!C:C,L2),IF(AND($E$3>=DATE(2024,5,26),$E$3<=DATE(2024,6,25)),SUMIFS(生产汇总表!L:L,生产汇总表!$B:$B,">=2024-5-26",生产汇总表!$B:$B,"<=2024-6-25",生产汇总表!B:B,"<="&$E$3,生产汇总表!B:B,"<="&$E$3,生产汇总表!C:C,L2),IF(AND($E$3>=DATE(2024,4,26),$E$3<=DATE(2024,5,25)),SUMIFS(生产汇总表!L:L,生产汇总表!$B:$B,">=2024-4-26",生产汇总表!$B:$B,"<=2024-05-25",生产汇总表!B:B,"<="&$E$3,生产汇总表!B:B,"<="&$E$3,生产汇总表!C:C,L2),IF(AND($E$3>=DATE(2024,3,26),$E$3<=DATE(2024,4,25)),SUMIFS(生产汇总表!L:L,生产汇总表!$B:$B,">=2024-3-26",生产汇总表!$B:$B,"<=2024-04-25",生产汇总表!B:B,"<="&$E$3,生产汇总表!B:B,"<="&$E$3,生产汇总表!C:C,L2),IF(AND($E$3>=DATE(2024,2,26),$E$3<=DATE(2024,3,25)),SUMIFS(生产汇总表!L:L,生产汇总表!$B:$B,">=2024-2-26",生产汇总表!$B:$B,"<=2024-03-25",生产汇总表!B:B,"<="&$E$3,生产汇总表!B:B,"<="&$E$3,生产汇总表!C:C,L2),IF(AND($E$3>=DATE(2024,1,26),$E$3<=DATE(2024,2,25)),SUMIFS(生产汇总表!L:L,生产汇总表!$B:$B,">=2024-1-26",生产汇总表!$B:$B,"<=2024-2-25",生产汇总表!B:B,"<="&$E$3,生产汇总表!B:B,"<="&$E$3,生产汇总表!C:C,L2),IF(AND($E$3>=DATE(2023,12,26),$E$3<=DATE(2024,1,25)),SUMIFS(生产汇总表!L:L,生产汇总表!$B:$B,">=2023-12-26",生产汇总表!$B:$B,"<=2024-01-25",生产汇总表!B:B,"<="&$E$3,生产汇总表!B:B,"<="&$E$3,生产汇总表!C:C,L2),""))))))))))))
|