如何通过使用VBA单击它来更改excel中单元格的值?

时间:2013-06-14 20:19:18

标签: excel excel-vba vba

我已经在谷歌搜索了一段时间,我似乎无法找到答案。

我有一个单元格显示“在服务中”,一旦你点击它,使用VBA,我希望它改为“不在服务中”,如果再次点击它,它将返回到“In服务”。你会怎么做呢?

感谢您的时间:D

1 个答案:

答案 0 :(得分:3)

这样可行:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Value = "In service" Then
        Target = "Out of service"
    ElseIf Target.Value = "Out of service" Then
        Target = "In service"
    End If
End Sub