在Excel中单击鼠标单击更改单元格的颜色

我试图创build一个工作表,我们的员工可以点击一个单元格来突出显示它正在处理任务,然后在完成时再次单击它,如果他们需要清除突出。 到目前为止,我已经拿出了下面的工作,除了我必须点击另一个单元格,再次回到同一个单元格,否则它将尝试编辑单元格。 我只想1点击颜色变化,另一个点击相同的单元格颜色变化2,另一个点击相同的单元格颜色变化3。有没有办法做到这一点?

Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'If the target cell is clear If Target.Interior.ColorIndex = xlNone Then 'Then change the background to the specified color Target.Interior.ColorIndex = 6 'But if the target cell is already the specified color ElseIf Target.Interior.ColorIndex = 6 Then 'Then change the background to the specified color Target.Interior.ColorIndex = 3 'But if the target cell is already the specified color ElseIf Target.Interior.ColorIndex = 3 Then 'Then clear the background color Target.Interior.ColorIndex = xlNone End If End Sub 

使用此代码在同一个工作表中添加BeforeDoubleClick事件:

 Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Cancel = True Worksheet_SelectionChange Target End Sub