如何使用条件格式在Excel中突出显示行

Conditional formatting lets you format cells in an Excel spreadsheet based on the cells’ content. For example, you could have a cell turn red when it contains a number lower than 100. You can also use conditional formatting to highlight an entire row?

通过条件格式设置,您可以基于单元格的内容来格式化Excel电子表格中的单元格。 例如,当单元格包含的数字小于100时,它可能会变成红色。您还可以使用条件格式突出显示整个行吗?

If you’ve never used Conditional Formatting before, you might want to look at Using Conditional Cell Formatting in Excel 2007. It’s for an earlier version of Excel, but the interface really hasn’t changed much. That guide talks about formatting specific cells based on their content. For example, say you use a spreadsheet to track hours that employees have worked. You could use conditional formatting to color cells red where an employee has worked more than eight hours in a particular day.

如果您以前从未使用过条件格式设置,则可能需要查看在Excel 2007使用条件单元格格式设置。 它用于早期版本的Excel,但界面的确没有太大变化。 该指南讨论了根据特定单元格的内容设置格式。 例如,假设您使用电子表格来跟踪员工的工作时间。 您可以使用条件格式将员工在特定一天工作超过8个小时的单元格涂成红色。

But what if you wanted to use a cell’s value to highlight other cells? In the example we’re using for this article, we’ve got a small spreadsheet with movies and just a couple of details about those movies (to keep thinks simple). We’re going to use conditional formatting to highlight all the rows with movies made before 1980.

但是,如果您想使用一个单元格的值突出显示其他单元格该怎么办? 在本文所使用的示例中,我们有一个包含电影的小型电子表格,并且仅包含有关这些电影的一些详细信息(以保持简单性)。 我们将使用条件格式来突出显示1980年前制作的电影的所有行。

第一步:创建表格 (Step One: Create Your Table)

Obviously, the first thing you need is a simple table containing your data. The data doesn’t have to be text-only; you can use formulas freely. At this point, your table has no formatting at all:

显然,您需要的第一件事是一个包含数据的简单表。 数据不必是纯文本的。 您可以自由使用公式。 此时,您的表完全没有格式:

第二步:格式化表格 (Step Two: Format Your Table)

Now it’s time to format your table, if you want. You can use Excel’s “simple” formatting tools or take a more hands-on approach, but it’s best only to format only those parts that won’t be affected by conditional formatting. In our case, we can safely set a border for the table, as well as format the header line.

如果需要,现在是时候格式化表格了。 您可以使用Excel的“简单”格式化工具,也可以采用更实际的方法,但是最好仅格式化那些不受条件格式化影响的部分。 在我们的情况下,我们可以安全地为表格设置边框,以及设置标题行的格式。

第三步:创建条件格式规则 (Step Three: Create The Conditional Formatting Rules)

Now we come to the meat and potatoes. As we said at the outset, if you’ve never used conditional formatting before, you should probably check out our earlier primer on the subject and once you’ve got that down, come back here. If you’re already somewhat familiar with conditional formatting (or just adventurous), let’s forge on.

现在我们来谈谈肉和土豆。 就像我们一开始所说的,如果您以前从未使用过条件格式,则可能应该查看有关该主题的更早的入门知识,一旦发现该问题,请回到此处。 如果您已经对条件格式有所了解(或者只是冒险),那就继续吧。

Select the first cell in the first row you’d like to format, click the “Conditional Formatting” button in the “Styles” section of the “Home” tab, and then select “Manage Rules” from the dropdown menu.

选择要格式化的第一行中的第一个单元格,单击“主页”选项卡的“样式”部分中的“条件格式”按钮,然后从下拉菜单中选择“管理规则”。

In the “Conditional Formatting Rules Manager” window, click the “New Rule” button.

在“条件格式规则管理器”窗口中,单击“新规则”按钮。

In the “New Formatting Rule” window, select the “Use a formula to determine which cells to format” option. This is the trickiest part. Your formula must evaluate to “True” for the rule to apply, and must be flexible enough so you could use it across your entire table later on. Here, we’re using the formula:

在“新格式设置规则”窗口中,选择“使用公式确定要格式化的单元格”选项。 这是最棘手的部分。 您的公式必须计算为“ True”才能应用该规则,并且必须足够灵活,以便以后可以在整个表中使用它。 在这里,我们使用公式:

=$D4<1980

The =$D4 part of the formula denotes the address of the cell I want to examine. D is the column (with the movie release date), and 4 is my current row. Note the dollar sign before the D . If you don’t include this symbol, then when you apply conditional formatting to the next cell, it would examine E5. Instead, you need to specify have a “fixed” column ( $D ) but a “flexible” row ( 4 ), because you are going to apply this formula across multiple rows.

公式的=$D4部分表示我要检查的单元格的地址。 D是列(带有电影上映日期),而4是我当前的行。 注意D前面的美元符号。 如果不包括此符号,则当您将条件格式应用于下一个单元格时,它将检查E5。 相反,您需要指定一个“固定”列( $D )但一个“灵活”行( 4 ),因为您将在多个行上应用此公式。

The <1980 part of the formula is the condition that has to be met. In this case, we’re going for a simple condition—the number in the release date column should be less than 1980. Of course, you can use much more complex formulas if you need to.

公式的<1980部分是必须满足的条件。 在这种情况下,我们需要一个简单的条件-发布日期列中的数字应小于1980。当然,如果需要,可以使用更复杂的公式。

So in English, our formula is true whenever the cell in column D in the current row has a value less than 1980.

因此,用英语来说,只要当前行D列中的单元格的值小于1980,我们的公式就成立。

Next, you’ll define the formatting that happens if the formula is true. In the same “New Formatting Rule” window, click the “Format” button.

接下来,您将定义公式为true时发生的格式。 在同一“新格式设置规则”窗口中,单击“格式”按钮。

In the “Format Cells” window, go through the tabs and tweak the settings until you get the look you want. In our example, we’re just going to change the fill color to green on the “Fill” tab. When you’re done applying your formatting, click the “OK” button.

在“设置单元格格式”窗口中,浏览选项卡并调整设置,直到获得所需的外观。 在我们的示例中,我们将要在“填充”选项卡上将填充颜色更改为绿色。 套用格式后,请按一下[确定]按钮。

Back in the “New Formatting Rule” window, you can now see a preview of your cell. If you’re happy with the way everything looks, click the “OK” button.

返回“新格式设置规则”窗口,现在您可以看到单元格的预览。 如果您对所有外观都满意,请单击“确定”按钮。

You should now be back to the “Conditional Formatting Rules Manager” window. Move the window a bit until you can see your spreadsheet behind it, and then click the “Apply” button. If the formatting of your selected cell changes, that means your formula is correct. If the formatting doesn’t change, you need to go a few steps back and tweak your formula until it does work. Here, you can see that our formula worked, and the cell we selected is now filled in green.

现在,您应该回到“条件格式规则管理器”窗口。 稍微移动窗口,直到可以看到其后面的电子表格,然后单击“应用”按钮。 如果所选单元格的格式发生更改,则表示您的公式正确。 如果格式没有改变,则需要向后退几步并调整公式,直到它起作用为止。 在这里,您可以看到我们的公式有效,并且我们选择的单元格现在用绿色填充。

Now that you have a working formula, it’s time to apply it across the entire table. As you can see above, right now the formatting applies only to the cell we started off with. In the “Conditional Formatting Rules Manager” window (which should still be open), click the up arrow to the right of the “Applies To” field.

现在您有了一个有效的公式,是时候将其应用于整个表格了。 如您在上方所见,现在格式化仅适用于我们开始使用的单元格。 在“条件格式设置规则管理器”窗口(应仍打开)中,单击“适用于”字段右侧的向上箭头。

The “Conditional Formatting Rules Manager” window collapses, giving you access to your spreadsheet. Drag to resize the current selection across the entire table (except for the headings).

“条件格式设置规则管理器”窗口折叠起来,使您可以访问电子表格。 拖动以在整个表中调整当前选择的大小(标题除外)。

When you’re done, click the down arrow to the right of the address field to get back to the full “Conditional Formatting Rules Manager” window.

完成后,单击地址字段右侧的向下箭头以返回到完整的“条件格式设置规则管理器”窗口。

Note that the “Applies to” field now contains a range of cells instead of just a single address. Click the “Apply” button again, and you should see the whole table formatted according to your rule. In our example, you can see that the whole rows that contain movies made before 1980 are filled with green.

请注意,“适用于”字段现在包含一个单元格区域,而不只是一个地址。 再次单击“应用”按钮,您应该会看到根据您的规则格式化的整个表格。 在我们的示例中,您可以看到包含1980年之前制作的电影的整行都充满了绿色。

That’s it! If you have more complex needs, you can create additional formulas. And, of course, you can make your formulas a whole lot more complex than the simple example we’ve used here. You can even use conditional formatting between different spreadsheets, so that cells or rows in one spreadsheet are formatted differently depending on the data in a whole different sheet. Play around with the techniques we’ve covered, and in no time you’ll be creating intricate spreadsheets with data that pops right off the screen.

而已! 如果您有更复杂的需求,则可以创建其他公式。 而且,当然,您可以使您的公式比我们在此使用的简单示例复杂得多。 您甚至可以在不同电子表格之间使用条件格式,以便一个电子表格中的单元格或行根据整个不同工作表中的数据而采用不同的格式。 体验我们介绍的技术,您将立即创建复杂的电子表格,其中的数据会立即弹出屏幕。

翻译自: https://www.howtogeek.com/howto/45670/how-to-highlight-a-row-in-excel-using-conditional-formatting/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值