如何在Excel中逐行计算有色单元格

发布于 2025-01-23 08:54:49 字数 307 浏览 0 评论 0原文

我有一个在Excel中的报告,其中有三行,并有条件格式以对数据进行涂抹。我本质上希望第四列输出1,如果该行中的至少两个单元格为绿色,则为0。示例:该行中的任何两个单元均可为绿色

“”

所以我希望一个公式在E4中输出1,但对于E列的其余部分。这是可能的吗?

I have a report in excel with three rows with conditional formatting to color map the data. I essentially want the fourth column to output a 1 if at least two cells within the row are green and a 0 if not. Example:any two cells in the row can be green

So I would like a formula to output a 1 in E4 but 0 for the rest of column E. Is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天生の放荡 2025-01-30 08:54:49

您必须创建这样的VBA函数:

Function ColorComparer(rColor1 As Range, rColor2 As Range, rColor3 As Range) As String

Dim vResult As String
Dim greenCounter As Integer

iCol1 = rColor1.Interior.Color
iCol2 = rColor2.Interior.Color
iCol3 = rColor3.Interior.Color
green = RGB(0, 255, 0)
greenCounter = 0


If iCol1 = green Then
    greenCounter = greenCounter + 1
End If

If iCol2 = green Then
    greenCounter = greenCounter + 1
End If

If iCol3 = green Then
    greenCounter = greenCounter + 1
End If

If greenCounter >= 2 Then
    vResult = 1
Else
    vResult = 0
End If

ColorComparer = vResult

End Function

绿色已将RGB设置为RGB(0、255、0),但您可以更改为想要使用的任何颜色

使用方式:

最好的问候。

You have to create a VBA function like this:

Function ColorComparer(rColor1 As Range, rColor2 As Range, rColor3 As Range) As String

Dim vResult As String
Dim greenCounter As Integer

iCol1 = rColor1.Interior.Color
iCol2 = rColor2.Interior.Color
iCol3 = rColor3.Interior.Color
green = RGB(0, 255, 0)
greenCounter = 0


If iCol1 = green Then
    greenCounter = greenCounter + 1
End If

If iCol2 = green Then
    greenCounter = greenCounter + 1
End If

If iCol3 = green Then
    greenCounter = greenCounter + 1
End If

If greenCounter >= 2 Then
    vResult = 1
Else
    vResult = 0
End If

ColorComparer = vResult

End Function

The green color has been set to RGB (0, 255, 0) but you can change to any color you want

Way to use:

Only one green

Two greens

Best regards.

巨坚强 2025-01-30 08:54:49

我可以想到两个选项:

  1. 创建一个与条件格式一致的公式 - 以前的贡献者已经提出了这一点。但是,这实际上没有检查单元颜色。

  2. 使用VBA脚本。这可以评估单元颜色,并且可以在事件驱动的情况下进行设置,因此它会在新的工作表条目上自动运行。

There are two options that I can think of:

  1. create a formula that aligns with the conditional formatting - this has already been suggested by previous contributors. However, this does not actually check cell colors.

  2. use a vba script. This can assess cell colors and can be setup as event driven so it runs automatically upon a new worksheet entry.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文