ThisWorkbook calls this handler Workbook_SheetChange and takes two arguments: Sh (of type Object ) and Target (a Range ). This way your code will not work.
If you place your code on the desired sheet ( Sheet1 , for example), and not on ThisWorkbook , put End If and change the range to โA1: G25โ (representing the square from column 1 of row A to row 25 of column 25), it should work. It is happened:
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Target.Worksheet.Range("A1:G25")) Is Nothing Then MsgBox "changed" End If End Sub
For completeness, thisWorkbook will work:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) If Not Intersect(Target, Target.Worksheet.Range("A1:G25")) Is Nothing Then MsgBox "changed" End If End Sub
source share