简体   繁体   English

在前导列中合并行与行的交替颜色-Excel 2016

[英]Alternating Color of Rows with Merged Rows in Leading Column - Excel 2016

I'm trying to create an Excel sheet that will be tracking some of our autonomous processes and their access privileges at my company and I've run into an issue with Excel.. 我正在尝试创建一个Excel工作表,该工作表将跟踪我们公司的一些自主流程及其访问权限,但是我遇到了Excel问题。

I'm trying to alternate row colors, which in and of itself isn't an issue, however the fact that I've got merged rows are giving me issues. 我正在尝试替换行颜色,这本身并不是问题,但是我合并行的事实给了我麻烦。

As of right now I've got 5 columns with headers in A through E. Column F is being used for conditional formatting to color the rows. 截至目前,我在A到E中有5列带有标题的列。列F用于条件格式化以为行着色。 In column F this formula is present: 在F列中,存在以下公式:

=MOD(IF(ROW()=2,0,IF(A2=A1,F1, F1+1)), 2)

This works great if I want to repeat the leading Column item over and over, however I'd like to reduce the visual clutter and increase clarity, so I've merged some of the rows in the Column A because multiple rows in B:E correspond to it. 如果我想一遍又一遍地重复最前面的Column项,这会很好用,但是我想减少视觉混乱并增加清晰度,所以我合并了Column A中的某些行,因为B:E中有多行对应它。

I've merged A2:A4 right now and the formula picks up the A2 and A4 as blank, but A3 (the text in the merged cell is centered) is recognized as different that A2 and A4 because the text resides there. 我现在已经合并了A2:A4,该公式将A2和A4选为空白,但是A3(合并单元格中的文本居中)被识别为与A2和A4不同,因为该文本位于此处。 I'll upload an image to give a better idea of what I'm talking about as well. 我还将上传图片,以更好地了解我在说什么。

If anyone can give me a tip on how to alternate row colors with merged cells/rows that'd be great, I've done a lot of googling and searching on stackoverflow, but for the most part I've only found things that pertain to unmerged rows/cells. 如果有人可以给我提示如何与合并的单元格/行交替显示行颜色的技巧,那么我已经做了很多搜索和搜索stackoverflow的工作,但是在大多数情况下,我只发现了相关的内容到未合并的行/单元格。

Image Example: https://imgur.com/a/UDbRVWA 图片示例: https//imgur.com/a/UDbRVWA

=IF() Condition that worked for me: = IF()对我有用的条件:

=MOD(IF(ROW()=2,0,IF((A2=0),IF((OR(A1<>0,A2=A1)),F1, F1+1),F1+1)), 2)

There is an answer below with a picture I posted, however, for most situations I would recommend the method suggested by @BruceWayne. 以下是我发布的图片的答案,但是,在大多数情况下,我建议使用@BruceWayne建议的方法。 It's far more sensible than working with merged cells! 比使用合并的单元格更明智!

Might I make a suggestion? 我可以提出建议吗? If the merging rows is to increase clarity with repeated entries, perhaps we can use another Conditional Formatting rule to make it more legible. 如果合并的行是为了增加重复条目的清晰度,也许我们可以使用另一条条件格式规则使其更清晰。

Say you have data that looks like this: 假设您有如下数据:

在此处输入图片说明

But, we don't want to see <Process #> duplicates in the A column. 但是,我们不想在A列中看到<Process #>重复项。 We could merge these cells and center it along the rows. 我们可以合并这些单元格并将其沿行居中。 But again, merging cells is generally frowned upon I've found. 但是,再次发现,合并单元格通常会令我皱眉。 (It makes it tricky to format, conditional format, copy/paste, do any VLOOKUP() / Index/Match , etc.) (这使格式,条件格式,复制/粘贴,执行任何VLOOKUP() / Index/Match等困难)

First, let's get the rows alternating colors. 首先,让我们让行交替显示颜色。 I'm using fill of RGB(183, 255, 253): 我正在使用RGB(183,255,253)的填充:

New Rule 1 - 新规则1-
Formula: =MOD(ROW(),2) 公式: =MOD(ROW(),2)
Applies To Range: $A$2:$E$9 适用范围: $A$2:$E$9
Format: Fill with color RGB 183, 255, 253 (...or whatever you want, just note the RGB for later) 格式:填入RGB 183、255、253颜色(...或您想要的任何颜色,请注意RGB,以备后用)

Now, we get this: 现在,我们得到这个: 在此处输入图片说明

Okay, making progress. 好的,取得进展。 Now, let's work on hiding the duplicate values in column A. 现在,让我们隐藏A列中的重复值。

So, let's apply some more Conditional Formats. 因此,让我们应用更多的条件格式。 We'll need two for column A, one to set the font to White, one to set the Font to that blue fill color. A列需要两个,一个将字体设置为白色,一个将字体设置为蓝色填充颜色。

New Rule 2 - 新规则2-
Formula: =AND($A3=$A2,MOD(ROW(),2)=1) 公式: =AND($A3=$A2,MOD(ROW(),2)=1)
Applies To: =$A$3:$A$100 适用于: =$A$3:$A$100
Format: Font --> Color --> RGB(183, 255, 253) 格式:字体->颜色-> RGB(183,255,253)

New Rule 3 - 新规则3-
Formula: =AND($A3=$A2,MOD(ROW(),2)=0) 公式: =AND($A3=$A2,MOD(ROW(),2)=0)
Applies To: =$A$3:$A$100 适用于: =$A$3:$A$100
Format: Font --> Color --> White 格式:字体->颜色->白色

Now we have: 现在我们有:
在此处输入图片说明

IMO, we can do one more thing to clarify the breaks in Processes: IMO,我们可以做另外一件事来澄清流程中的中断:

New Rule 4 - 新规则4-
Formula: =$A2<>$A1 公式: =$A2<>$A1
Applies To: =$A$2:$E$100 适用于: =$A$2:$E$100
Format: Border --> Top Border 格式:边框->顶部边框

Now, we have a nice new CF table. 现在,我们有了一个不错的新CF表。 在此处输入图片说明

I ended up finding a solution with just some clever working with the Conditional IF() statements. 最后,我找到了一些巧妙的条件IF()语句解决方案。 I think the key was taking into account that the Merged Cells that weren't the top (ie If I merged A2:A4, A2 is top, A3, A4 bottom) were equal to 0 while the top was set to the value of the text within the merged cell. 我认为关键是考虑到不是顶部的合并单元格(即,如果我合并了A2:A4,则A2是顶部,A3,A4底部)等于0,而顶部设置为合并单元格中的文本。 Using the formula below I was able to achieve the result I was after: 使用下面的公式,我可以达到我想要的结果:

=MOD(IF(ROW()=2,0,IF((A2=0),IF((OR(A1<>0,A2=A1)),F1, F1+1),F1+1)), 2)

And here is a linked screenshot: https://imgur.com/a/gNaC62c 这是一个链接的屏幕截图: https : //imgur.com/a/gNaC62c

I then just added conditional formatting for every row but row 1: =$F2=1 . 然后,我只为除行1之外的每一行添加条件格式: =$F2=1 I'll be hiding column F to make it seem less obtrusive. 我将隐藏F列,以使其看起来不太引人注目。

For future reference, I would agree with what @BruceWayne mentioned in that a simpler formatting that gets the job done would be preferable. 为了将来参考,我同意@BruceWayne的观点,即最好采用一种更简单的格式来完成工作。 There are many other ways to format this in a way that makes much more sense, but I felt like I was close when I was tinkering with it, so I stuck with it another 15 minutes or so and was able to pull out a usable formatting condition. 还有许多其他方式可以使这种格式化更有意义,但是当我进行修补时,我感觉自己很亲密,因此我又坚持了15分钟左右,并且能够取出可用的格式化条件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM