![]() |
running a macro after updating a cell
Hello,
Wanted to know if it is possible in Excel to run a macro after updating a cell.. For example, I wanted excel to "date stamp" cell B1 (using a macro) after cell A1 has been updated. Is that possible...thanx |
running a macro after updating a cell
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub Application.EnableEvents = False Range("B1").Value = Date Application.EnableEvents = True End Sub This is worksheet code it goes in the worksheet code area, NOT a standard module. -- Gary''s Student - gsnu200749 "Shahid" wrote: Hello, Wanted to know if it is possible in Excel to run a macro after updating a cell.. For example, I wanted excel to "date stamp" cell B1 (using a macro) after cell A1 has been updated. Is that possible...thanx |
running a macro after updating a cell
Thanks..that works great..
Another follow on question would be: Could I be done to a whole column...so that every time you change an entry on each row, it updates the date in the column besides it. thanks "Gary''s Student" wrote: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub Application.EnableEvents = False Range("B1").Value = Date Application.EnableEvents = True End Sub This is worksheet code it goes in the worksheet code area, NOT a standard module. -- Gary''s Student - gsnu200749 "Shahid" wrote: Hello, Wanted to know if it is possible in Excel to run a macro after updating a cell.. For example, I wanted excel to "date stamp" cell B1 (using a macro) after cell A1 has been updated. Is that possible...thanx |
running a macro after updating a cell
Yes. We change two lines of code:
Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub -- Gary''s Student - gsnu200749 "Shahid" wrote: Thanks..that works great.. Another follow on question would be: Could I be done to a whole column...so that every time you change an entry on each row, it updates the date in the column besides it. thanks "Gary''s Student" wrote: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub Application.EnableEvents = False Range("B1").Value = Date Application.EnableEvents = True End Sub This is worksheet code it goes in the worksheet code area, NOT a standard module. -- Gary''s Student - gsnu200749 "Shahid" wrote: Hello, Wanted to know if it is possible in Excel to run a macro after updating a cell.. For example, I wanted excel to "date stamp" cell B1 (using a macro) after cell A1 has been updated. Is that possible...thanx |
running a macro after updating a cell
again works great..
another follow on question :-) At present I've got it running with F:F being updated and a date being inserted into G:G. Could I also have it doing the same thing on the same sheet for G:G to H:H, I:I to J:J etc.. I tried to copy the code and edit it to give each module uniqueness but that didn't work... "Gary''s Student" wrote: Yes. We change two lines of code: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub -- Gary''s Student - gsnu200749 "Shahid" wrote: Thanks..that works great.. Another follow on question would be: Could I be done to a whole column...so that every time you change an entry on each row, it updates the date in the column besides it. thanks "Gary''s Student" wrote: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub Application.EnableEvents = False Range("B1").Value = Date Application.EnableEvents = True End Sub This is worksheet code it goes in the worksheet code area, NOT a standard module. -- Gary''s Student - gsnu200749 "Shahid" wrote: Hello, Wanted to know if it is possible in Excel to run a macro after updating a cell.. For example, I wanted excel to "date stamp" cell B1 (using a macro) after cell A1 has been updated. Is that possible...thanx |
running a macro after updating a cell
How did you edit it?
On Oct 9, 9:16 am, Shahid wrote: again works great.. another follow on question :-) At present I've got it running with F:F being updated and a date being inserted into G:G. Could I also have it doing the same thing on the same sheet for G:G to H:H, I:I to J:J etc.. I tried to copy the code and edit it to give each module uniqueness but that didn't work... "Gary''s Student" wrote: Yes. We change two lines of code: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub -- Gary''s Student - gsnu200749 "Shahid" wrote: Thanks..that works great.. Another follow on question would be: Could I be done to a whole column...so that every time you change an entry on each row, it updates the date in the column besides it. thanks "Gary''s Student" wrote: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub Application.EnableEvents = False Range("B1").Value = Date Application.EnableEvents = True End Sub This is worksheet code it goes in the worksheet code area, NOT a standard module. -- Gary''s Student - gsnu200749 "Shahid" wrote: Hello, Wanted to know if it is possible in Excel to run a macro after updating a cell.. For example, I wanted excel to "date stamp" cell B1 (using a macro) after cell A1 has been updated. Is that possible...thanx |
running a macro after updating a cell
I added created another couple SUBS by using the text and editing the column
value. e.g. Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub Private Sub Worksheet_Change2 (ByVal Target As Range) If Intersect(Target, Range("H:H")) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub "dan dungan" wrote: How did you edit it? On Oct 9, 9:16 am, Shahid wrote: again works great.. another follow on question :-) At present I've got it running with F:F being updated and a date being inserted into G:G. Could I also have it doing the same thing on the same sheet for G:G to H:H, I:I to J:J etc.. I tried to copy the code and edit it to give each module uniqueness but that didn't work... "Gary''s Student" wrote: Yes. We change two lines of code: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub -- Gary''s Student - gsnu200749 "Shahid" wrote: Thanks..that works great.. Another follow on question would be: Could I be done to a whole column...so that every time you change an entry on each row, it updates the date in the column besides it. thanks "Gary''s Student" wrote: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub Application.EnableEvents = False Range("B1").Value = Date Application.EnableEvents = True End Sub This is worksheet code it goes in the worksheet code area, NOT a standard module. -- Gary''s Student - gsnu200749 "Shahid" wrote: Hello, Wanted to know if it is possible in Excel to run a macro after updating a cell.. For example, I wanted excel to "date stamp" cell B1 (using a macro) after cell A1 has been updated. Is that possible...thanx |
running a macro after updating a cell
I'm stumped.
On Oct 10, 1:39 am, Shahid wrote: I added created another couple SUBS by using the text and editing the column value. e.g. Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub Private Sub Worksheet_Change2 (ByVal Target As Range) If Intersect(Target, Range("H:H")) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub "dan dungan" wrote: How did you edit it? On Oct 9, 9:16 am, Shahid wrote: again works great.. another follow on question :-) At present I've got it running with F:F being updated and a date being inserted into G:G. Could I also have it doing the same thing on the same sheet for G:G to H:H, I:I to J:J etc.. I tried to copy the code and edit it to give each module uniqueness but that didn't work... "Gary''s Student" wrote: Yes. We change two lines of code: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Application.EnableEvents = True End Sub -- Gary''s Student - gsnu200749 "Shahid" wrote: Thanks..that works great.. Another follow on question would be: Could I be done to a whole column...so that every time you change an entry on each row, it updates the date in the column besides it. thanks "Gary''s Student" wrote: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub Application.EnableEvents = False Range("B1").Value = Date Application.EnableEvents = True End Sub This is worksheet code it goes in the worksheet code area, NOT a standard module. -- Gary''s Student - gsnu200749 "Shahid" wrote: Hello, Wanted to know if it is possible in Excel to run a macro after updating a cell.. For example, I wanted excel to "date stamp" cell B1 (using a macro) after cell A1 has been updated. Is that possible...thanx |
All times are GMT +1. The time now is 08:04 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com