Excel 中的条件格式问题 - 公式帮助

发布于 2024-11-27 03:55:01 字数 122 浏览 1 评论 0原文

我需要一个用于条件格式的宏。我需要如果一行包含一个为 1 的单元格,那么我需要突出显示整行(例如 A1 - E1)。

目前我只设法突出显示包含数字 1 的单元格,而不是整行。有什么想法吗?

提前致谢

I need a macro to be used in conditional formatting. I need that if a row contains a cell that is 1, then i need that the whole row is highlighted (e.g. A1 - E1).

at the moment i only managed to highlight the cells containing number 1, but not the whole row. any ideas ?

thanks in advance

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

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

发布评论

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

评论(1

日记撕了你也走了 2024-12-04 03:55:01

要在 Excel 中执行此操作,请选择 A1:E1,然后选择“格式”>“A1:E1”。条件格式...>式为> =SUMIF($A1:$E1,"=1")>0。不要忘记 $ 美元符号,以指定对 A 到 E 列的绝对(而不是相对)引用!

这是在宏中执行相同操作的 VBA 代码:

With Range("A1:E1")
    ' If you need to delete any "pre-existing conditions" 
    ' (no US healthcare reform pun intended) then uncomment the following line: 
    '.FormatConditions.Delete 

    .FormatConditions.Add Type:=xlExpression, _
         Formula1:="=SUMIF($A1:$E1,""=1"")>0"
    .FormatConditions(1).Interior.ColorIndex = 6 ' yellow background
End With

To do it in Excel, select A1:E1, then Format > Conditional Formatting... > Formula Is > =SUMIF($A1:$E1,"=1")>0. Don't forget the $ dollar signs, to specify an absolute (and not a relative) reference to columns A to E!

This is the VBA code to do the same thing in a macro:

With Range("A1:E1")
    ' If you need to delete any "pre-existing conditions" 
    ' (no US healthcare reform pun intended) then uncomment the following line: 
    '.FormatConditions.Delete 

    .FormatConditions.Add Type:=xlExpression, _
         Formula1:="=SUMIF($A1:$E1,""=1"")>0"
    .FormatConditions(1).Interior.ColorIndex = 6 ' yellow background
End With
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文