在Excel中合并一堆IF和AND公式?

时间:2017-07-17 06:46:32

标签: excel conditional-formatting

有没有办法将这些公式合并为一个?

我正在尝试有条件地将行格式化为特定颜色。

=IF(AND(ISNUMBER(SEARCH("TR",$B1))),($F1<>""))
=IF(AND(ISNUMBER(SEARCH("TR",$B1))),(AND($F1<>"",$G1<>"")))
=IF(AND(ISNUMBER(SEARCH("TR",$B1))),(AND($F1<>"",$G1<>"",$H1<>"")))
=IF(AND(ISNUMBER(SEARCH("TR",$B1))),(AND($F1<>"",$G1<>"",$H1<>"",$I1<>""))
=IF(AND(ISNUMBER(SEARCH("TR",$B1))),(AND($F1<>"",$G1<>"",$H1<>"" ,$I1<>"",$J1<>"")))
=IF(AND(ISNUMBER(SEARCH("TR",$B1))),(AND($F1<>"",$G1<>"",$H1<>"",$I1<>"",$J1<>"",$K1<>"")))
=IF(AND(ISNUMBER(SEARCH("TR",$B1))),(AND($F1<>"",$G1<>"",$H1<>"",$I1<>"",$J1<>"",$K1<>"",$L1<>"")))
=IF(AND(ISNUMBER(SEARCH("TR",$B1))),(AND($F1<>"",$G1<>"",$H1<>"",$I1<>"",$J1<>"",$K1<>"",$L1<>"",$M1<>"")))

2 个答案:

答案 0 :(得分:0)

根据您希望如何详细使用它,可能会有所不同......

=IF(AND(ISNUMBER(SEARCH("TR",$B1))),AND($F1:F1<>""))

答案 1 :(得分:0)

有几种方法可以检查范围内的所有单元格是否为非空,而不是像这样的长路

AND($F1<>"", $G1<>"", $H1<>"", $I1<>"", $J1<>"", $K1<>"", $L1<>"", $M1<>"")

最简单的方法是

COUNTA($F1:$M1) <> 0

COUNTBLANK($F1:$M1)=0

您也可以使用array formula。输入=IF(AND(ISNUMBER(SEARCH("TR", $B1))), NOT(ISBLANK($F1:$M1))),然后按 Ctrl + Shift + 输入

另一种解决方案是使用SUMPRODUCT

=SUMPRODUCT(--($F1:$M1<>"")) <> 0