【问题标题】:Coloring Cells in Excel 2013Excel 2013 中的单元格着色
【发布时间】:2014-07-31 06:41:54
【问题描述】:

我想在 Excel 2013 中查看一个命名的单元格区域,如果这些单元格中的文本是白色的,那么我想将该单元格右侧的单元格中的文本颜色设置为白色.任何人都可以帮助这个可怜的vba编程新手吗?非常感激。祝你有美好的一天!

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Range("DateOut").Select
    For Each Cell In Selection
        If Cell.Font.ColorIndex = 2 Then
            Cell.Offset(, 1).Font.ColorIndex = 2
        End If
    Next

    End Sub

【问题讨论】:

  • This: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Range("DateOut").Select For Each cell in Selection If Cell.Font.ColorIndex = 2 Then Cell.Offset(, 1).Font .ColorIndex = 2 End If Next End Sub
  • 使用此代码更新您的问题 - 在 cmets 中无法读取
  • 抱歉,如何让它在 cmets @simoco 中显示代码

标签: vba excel


【解决方案1】:

代码运行良好

   Private Sub Worksheet_SelectionChange(ByVal Target As Range)    
    Range("DateOut").Select
    For Each Cell In Selection
        If Cell.Font.ColorIndex = 2 Then
            Cell.Offset(, 1).Font.ColorIndex = 2
        End If
    Next    
    End Sub

您在哪个部分遇到问题? 如果您在添加代码时遇到问题

  • 右键单击工作表名称并选择查看代码并粘贴

【讨论】:

    【解决方案2】:

    请尝试:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
         For Each Cell In Range("DateOut")
         If Cell.Font.ColorIndex = 2 Then Cell.Offset(, 1).Font.ColorIndex = 2
         Next
    End Sub
    

    【讨论】:

      猜你喜欢
      • 2011-08-19
      • 1970-01-01
      • 1970-01-01
      • 2011-08-17
      • 1970-01-01
      • 2017-01-10
      • 2013-09-01
      • 2012-10-15
      相关资源
      最近更新 更多