excel VBA run macro automatically whenever a cell is changed

前端 未结 5 1638
礼貌的吻别
礼貌的吻别 2020-11-27 20:54

Is there a simple way to get Excel to automatically execute a macro whenever a cell is changed?

The cell in question would be in Worksheet(\"BigBoard\").Range(

5条回答
  •  长情又很酷
    2020-11-27 21:44

    Another option is

    Private Sub Worksheet_Change(ByVal Target As Range)
        IF Target.Address = "$D$2" Then
            MsgBox("Cell D2 Has Changed.")
        End If
    End Sub
    

    I believe this uses fewer resources than Intersect, which will be helpful if your worksheet changes a lot.

提交回复
热议问题