Trigger macro when any cell containing formula changes

后端 未结 2 1178
误落风尘
误落风尘 2021-01-27 22:49

I have a worksheet with about 50 cells (containing formulas) that changes depending on cells in an external workbook.

I want to trigger a certain macro when ANY of these

2条回答
  •  花落未央
    2021-01-27 23:29

    Maybe you can start with this code.

    Private Sub Worksheet_Change(ByVal Target As Range)
      Dim rIntersect As Range
      Set rIntersect = Intersect(Target, Application.names("NameOfRange").RefersToRange)
      If Not rIntersect Is Nothing Then
        MsgBox "found" '<~ change to your liking
      End If
    End Sub
    

提交回复
热议问题