I am trying to write a macro where changing any column
should automatically save worksheet.
My Excel sheet expands till G25.
I tried this but its not working:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Target.Worksheet.Range("G25")) Is Nothing Then
ActiveWorkbook.Save
End Sub
I have save it under ThisWorkBook.
Any help is appreciated.
Under ThisWorkbook that handler is called
Workbook_SheetChangeand it accepts two arguments, Sh (of typeObject) and Target (aRange). So, your code won’t work there.If you put your code in the sheet you want (Sheet1, for instance) instead of in the ThisWorkbook, put the
End Ifand change the range to “A1:G25” (representing a square from row 1 column A to row 25 column 25), it should work.This did:
For completeness, under ThisWorkbook, this will work: