你好!我使用一个 excel VBA 代码,当我单击彩色单元格时它会删除颜色,我需要对此代码进行小幅修改

Hello! I use an excel VBA code that when I click on a colored cell it removes the color, I need a small modification on this code

提问人:learningcodes 提问时间:10/27/2023 最后编辑:marc_slearningcodes 更新时间:10/27/2023 访问量:12

问:

我有这个 VBA 代码,我在我的 excel 工作表中使用了它,它运行良好,但我只需要对它进行一个小的修改,此代码会删除我在整个页面中任何位置单击的任何单元格上的背景颜色,我想做的是修改它以仅在某些列而不是整个页面上执行此操作, 具体来说,我需要它仅在 A 到 E 列以及从第 2 行开始处于活动状态;这是我的代码。

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
     
    If Not Target.Interior.ColorIndex = x1None Then
       i = Target.Interior.ColorIndex
        Select Case i
        Case xlNone
        Case Else
            Target.Interior.ColorIndex = x1None
        End Select
    End If
End Sub
颜色 背景 范围 单击

评论


答: 暂无答案