我想编写一个公式,如果所有特定的一组单元格都标记有“ X”,则返回“ True”。例如下面的....
A B C D E
1 X
2
3 X X
4 X
5 X
使用以下公式检查所有这些值是否均具有“ X”的一种方法
=IF( AND(A1 = "X", A3 = "X", B3 = "X", B4 = "X", C5 = "X"), "True", "false")
但是,A3:B3是类似的分组,但是比较语句无法识别出该目的
=IF( AND(A1 = "X", A3:B3 = "X", B4 = "X", C5 = "X"), "True", "false")
是否可以将一系列单元格与单个值进行比较?
答案 0 :(得分:1)
虽然不能使用大括号(例如var products = [{id:1,name:"Buzzy"},{id:2,name:"Bytrex"},{id:3,name:"CactiDance"},{id:4,name:"CactiLoops"},{id:5,name:"Cadaver Jelly"},{id:6,name:"Caffeine Serene"},{id:7,name:"Cajun Sation"},{id:8,name:"Call it Green"},{id:9,name:"Callflex"},{id:10,name:"Calling Card Shark"},{id:11,name:"Calque"},{id:12,name:"Camel Meal Tea"},{id:13,name:"Camelot Chamomile"},{id:14,name:"Campxotica"},{id:15,name:"Camus the Killer Tale"},{id:16,name:"Candecor"},{id:17,name:"Candelarium"},{id:18,name:"CandID"},{id:19,name:"Candlelight Vittles"},{id:20,name:"Candy Ask"},{id:21,name:"Candy Floss"}],
prices = [{id:6,price:55},{id:14,price:22},{id:15,price:57},{id:4,price:41},{id:18,price:9},{id:17,price:3},{id:2,price:73},{id:7,price:43},{id:5,price:78},{id:1,price:91},{id:8,price:58},{id:16,price:69},{id:13,price:74},{id:19,price:14},{id:21,price:25},{id:12,price:84},{id:20,price:8},{id:9,price:94},{id:10,price:36},{id:3,price:34},{id:11,price:71}];
prices.sort((a, b) => a.price - b.price)
.forEach(p => {
console.log(products.find(a => a.id === p.id))
})
和{
来构造单元格引用的不连续数组(例如}
,但可以使用大括号来构造字符串文字数组) (例如{A1, A3:B3, B4, C5}
和INDIRECT使用字符串文字来定义范围。
{"A1", "A3:B3", "B4", "C5"}
COUNTIF从由INDIRECT解释的字符串文字数组中生成结果数组。 SUM总共获取该结果数组。
产生一个准确的COUNTIF。如果您想要TRUE / FALSE,则将它们与所有X的结果进行比较。
=SUM(COUNTIF(INDIRECT({"A1","A3:B3","B4","C5"}),"X"))
这些不是不是数组公式。
答案 1 :(得分:1)
您还可以在第二张表中为要包含X的单元格设置模板,然后进行比较:
=SUMPRODUCT((Sheet1!A1:C5=Sheet2!A1:C5)*(Sheet1!A1:C5="X"))
或获得正确/错误的结果:
=SUMPRODUCT((Sheet1!A1:C5=Sheet2!A1:C5)*(Sheet1!A1:C5="X"))=COUNTA(Sheet2!A1:C5)
Sheet2(模板)
第1张(待比较)
答案 2 :(得分:0)
在输入第二个数字时使用Control-Shift-Enter来使用单个值之类的数组。
=IF( AND(A1 = "X", A3:B3 = "X", B4 = "X", C5 = "X"), "True", "false") <ctrl-shift-enter>
答案 3 :(得分:0)
在单元格F1中输入:
=IF(COUNTA(A1:E1)>=5, "True", "False")
在您提供的示例中,所有示例都应返回false。如果所有单元格中都有一个X,它将返回true。