首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >根据特定单元格的值对excel工作表的多个单元格进行着色

根据特定单元格的值对excel工作表的多个单元格进行着色
EN

Stack Overflow用户
提问于 2012-11-26 16:47:01
回答 1查看 622关注 0票数 1

我有一个excel sheet...where,我想根据以下条件对单元格进行着色:

  1. 如果E细胞非空,则A、B、C细胞、D细胞、F细胞、G细胞、H细胞和I细胞不能空。如果发现任何一个单元格为空,则将相应的单元格涂成红色!
  2. 如果所有的细胞A、B、C、D、F、G、H和I都包含一个值,细胞E是空的,那么用红色高亮显示细胞E。

注意:要在模块section...so中实现这一点,建议相应的解决方案!!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-26 17:44:20

像这样的东西有用吗?

代码语言:javascript
复制
Dim Row
Row = 3

If Not IsEmpty(Cells(Row, 5)) Then
    ' if Cell E is not empty, then highlight empty cols A-I
    For chkcol = 1 To 9
        If chkcol <> 5 Then ' ignore column E
            If IsEmpty(Cells(Row, chkcol)) Then
                Cells(Row, chkcol).Interior.ColorIndex = 3
            End If
        End If
    Next
Else
    blnvalid = True
    ' check for cell E being empty and all others not
    For chkcol = 1 To 9
        If chkcol <> 5 Then
            If IsEmpty(Cells(Row, chkcol)) Then
                blnvalid = False
                Exit For
            End If
        End If
    Next
    If blnvalid Then
        Cells(Row, 5).Interior.ColorIndex = 3
    End If
End If
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13569320

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档