[英]Conditional formatting inconsistent using MATCH in a custom formula
I have 2 cells A1
and B1
that contain the same values.我有 2 个包含相同值的单元格
A1
和B1
。 I want to create a conditional formatting rule using the custom formula =MATCH(A1,B1)
that colours both cells green.我想使用自定义公式
=MATCH(A1,B1)
创建条件格式规则,将两个单元格都染成绿色。
This sometimes works on other cell pairs but other times it simply doesn't work.这有时适用于其他细胞对,但有时它根本不起作用。
Note that the cells have a custom number format that adds a letter and a semi-colon before the numbers.请注意,单元格具有自定义数字格式,在数字前添加一个字母和一个分号。
Let me know what I am doing wrong.让我知道我做错了什么。
3 pairs, 2 pairs worked, Q3
& R3
didn't: 3 对,2 对起作用,
Q3
和R3
没有:
My conditional formatting:我的条件格式:
The cell references in your rule are relative.规则中的单元格引用是相对的。 This means that when the current cell is in a different row or column, the formula shifts accordingly.
这意味着当当前单元格位于不同的行或列时,公式会相应地移动。 Changes in the current row don't affect your rule, but changes in the current column number, that are not that in multiples of 2, mean the MATCH function's
range
argument uses the wrong column.当前行的更改不会影响您的规则,但当前列号的更改不是 2 的倍数,这意味着MATCH函数的
range
参数使用了错误的列。
You can see the behavior by putting =MATCH(Q3,R3,0)
in Q4
and then copy it to R4
.您可以通过将
=MATCH(Q3,R3,0)
放在Q4
中然后将其复制到R4
来查看行为。 The search_key
argument will automatically update to R3
and the range
argument to S3
. search_key
参数将自动更新为R3
和range
参数为S3
。 The new formula will be =MATCH(R3,S3,0)
, but you need the range
argument to be Q3
because R3
is in a right column: =MATCH(R3,Q3,0)
.新公式将为
=MATCH(R3,S3,0)
,但您需要range
参数为Q3
,因为R3
在右列中: =MATCH(R3,Q3,0)
。 This same thing is taking place in your conditional formatting rule.同样的事情也发生在您的条件格式规则中。
The following custom formula will work as expected.以下自定义公式将按预期工作。 It adjusts based on whether the current cell is the left, or the right column, of a column pair.
它根据当前单元格是列对的左列还是右列进行调整。
M3:R55
=MATCH(M3,OFFSET(M3,0,IF(ISODD(COLUMN($M3))=ISODD(COLUMN()),1,-1)),0)
M3:R55
, where each pair is comprised of a left and a right columnM3:R55
,其中每对由左列和右列组成search_key
argument is from a left-column cell, then its range
argument needs to be the cell OFFSET one column to the right of the search_key
.search_key
参数来自左列单元格,则其range
参数需要是search_key
右侧一列的单元格OFFSET 。
OFFSET(M3,0,1)
search_key
argument is from a right-column cell, then its range
argument needs to be the cell OFFSET one column to the left of the search_key
.search_key
参数来自右列单元格,则其range
参数需要是search_key
左侧一列的单元格OFFSET 。
OFFSET(M3,0,-1)
# First Column is M, current cell is Q3
=ISODD(COLUMN($M3))=ISODD(COLUMN())
=ISODD(13)=ISODD(17)
=TRUE=TRUE
=TRUE // current col is left
# First Column is M, current cell is R3
=ISODD(COLUMN($M3))=ISODD(COLUMN())
=ISODD(13)=ISODD(18)
=TRUE=FALSE
=FALSE // current col is right
# First Column is N, current cell is R3
=ISODD(COLUMN($N3))=ISODD(COLUMN())
=ISODD(14)=ISODD(18)
=FALSE=FALSE
=TRUE // current col is left
1
or -1
for the OFFSET function's range
argument:range
参数使用1
还是-1
:=MATCH(M3,OFFSET(M3,0,
IF(ISODD(COLUMN($M3))=ISODD(COLUMN()),
1, // condition_true (current col is left)
-1)) // condition_false (current col is right)
,0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.