VBA trigger macro on cell value change

前端 未结 4 1900
青春惊慌失措
青春惊慌失措 2020-12-17 05:07

This should be simple. When the value of a cell changes I want to trigger some VBA code. The cell (D3) is a calculation from two other cells =B3*C3. I have atte

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-17 05:26

    Could you try something like this? Change the formula to =D3AlertOnChange(B3*C3).

    Private D3OldVal As Variant
    
    Public Function D3AlertOnChange(val)
        If val <> D3OldVal Then MsgBox "Value changed!"
        D3OldVal = val
        D3AlertOnChange = val
    End Function
    

提交回复
热议问题