将条件格式复制到其他行 [英] Copy conditional formatting to other rows

查看:589
本文介绍了将条件格式复制到其他行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目列表,每个都有自己的代码,我希望用户按照任意顺序排列1到5。不是所有的项目都需要排名。但是,每个项目只能按一次排名(不重复)。我的样本记录表如下:

 
ID 1st 2nd 3rd 4th 5th

1 U74 L65 G56 N28 M82

2 N28 A11 L65 P37 L65

3 H72 R99 B42 Y95 G56

4 T63 C58 P37 B42 C58

(在这种情况下,用户ID 2和4分别具有重复的代码L65和C58)



突出显示单行中的重复代码很容易用条件格式化完成。我遇到的问题是如何将格式化复制到其余的行。我的实际数据集有超过300条记录,所以手动执行每一行并不是一个选择。

解决方案

如果你有这样的数据:





您只需要使用以下公式: = COUNTIF($ B2:$ F2,B2)> 1 br>
当然,您需要使用使用公式来确定要将格式的单元格作为规则类型:





您还需要定义应用格式的位置(在我们的示例中为 $ B $ 2:$ F $ 5 )。
或者您可以选择所需的整个范围在实际添加条件格式

之前格式化



结果将是:






$ b

Edit1:它是如何工作的? (for zipzit)



让我们检查公式: = COUNTIF($ B2:$ F2,B2)> 1

我们应用了哪些: $ B $ 2:$ F $ 5



在单元格格式中使用时,Excel单元格中的公式行为方式相同。

所以绝对和相对单元格地址( $ 而$ $ )也适用于它。

所以如果我们在 B2 ,它将评估 B2 中的值在 $ B2:$ F2 中使用多少次 COUNTIF 公式。



答案是1.在我们的公式中,只有格式化它是> 1

现在说我们将它复制到 C2 中。
请注意,我们公式中的 B2 在行和列上使用相对引用。
因此,不是评估 B2 再次针对 $ B2:$ F2 ,它将评估 C2
现在,为了确保它对同一套范围 $ B2:$ F2 进行评估,请注意我们在列地址之前加上 $



我有其他帖子关于 条件格式 ,您可能需要查看。


I have a list of items, each with its own code, that I would like the user to rank in an arbitrary order of preference 1st to 5th. Not all items need to be ranked. However, each item should only be ranked ONCE (no duplicates). My sample table of records is as follows:

ID  1st 2nd 3rd 4th 5th

1   U74 L65 G56 N28 M82

2   N28 A11 L65 P37 L65

3   H72 R99 B42 Y95 G56

4   T63 C58 P37 B42 C58

(In this instance, user ID 2 and 4 have duplicate codes L65 and C58 respectively)

Checking and highlighting duplicate codes in a single row is easily done with conditional formatting. The problem I'm running into is how to "copy" the formatting to the rest of the rows. My actual dataset has over 300 records, so doing it manually for each row is not really an option.

解决方案

If you have a data like this:

You just need to use this formula: =COUNTIF($B2:$F2,B2)>1
Of course you need to use Use a formula to determine which cell to format as a rule type:

And also you need to define where you'll apply the formatting ($B$2:$F$5 in our example).
Or you can select the entire range you want to format before actually adding the Conditional Format

The result would be:

Is this what you're trying?

Edit1: How it works? (for zipzit)

Let us examine the formula: =COUNTIF($B2:$F2,B2)>1
Which we applied in: $B$2:$F$5

Regular formula in Excel Cells behaves the same way when used in Conditional Formatting.
So absolute and relative cell address (with $ and without $) applies to it as well.
So if we apply the formula for example in B2 only, it will evaluate how many occurrence does the value in B2 have in $B2:$F2 using COUNTIF formula.

The answer is 1. In our formula, you'll only format it if it is >1.
Now say we copy it in C2.
Notice that B2 in our formula use relative referencing both on rows and column.
So instead of evaluating B2 again against $B2:$F2, it will evaluate C2.
Now, to make sure it will evaluate it against the same set of range $B2:$F2, notice that we precede the column address with $.

I have other post about Conditional Formatting which you might want to check out.

这篇关于将条件格式复制到其他行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆