Monday, November 2, 2015

How to get a macro to run when a cell/cells is/are changed on any worksheet of a specific workbook

Just write the following code on your "VBA Project" -> "This Workbook":

Private Sub Workbook_SheetChange(ByVal sh As Object, ByVal target As Range)

Dim KeyCells As Range

Set sh = ActiveSheet

    Set KeyCells = sh.Range("B20:e25")  ''''change the range to your range
   
    If Not Application.Intersect(KeyCells, sh.Range(target.Address)) _
           Is Nothing Then
         
                '''''''''''please write your code here'''''''''''''
    End If
   
  
End Sub