![]() |
can I use an update macro on multiple columns
Hello,
Am using the following code to run a macro after I update a cell within a column..It works fine on one column (F:F)..but I wanted it to do the same thing on multiple columns J:J, M:M, etc.... 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 Target.Offset(0, 2).Value = Environ("UserName") Application.EnableEvents = True If Intersect(Target, Range("F:F")) = "Complete" Then Target.Offset(0, 3).Value = "---" Target.Offset(0, 4).Select Else: End If End Sub Any help?? |
can I use an update macro on multiple columns
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("F:F,J:J,M:M")) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Target.Offset(0, 2).Value = Environ("UserName") Application.EnableEvents = True If Intersect(Target, Range("F:F,J:J,M:M")) = "Complete" Then Target.Offset(0, 3).Value = "---" Target.Offset(0, 4).Select Else: End If End Sub -- Regards, Tom Ogilvy "Shahid" wrote: Hello, Am using the following code to run a macro after I update a cell within a column..It works fine on one column (F:F)..but I wanted it to do the same thing on multiple columns J:J, M:M, etc.... 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 Target.Offset(0, 2).Value = Environ("UserName") Application.EnableEvents = True If Intersect(Target, Range("F:F")) = "Complete" Then Target.Offset(0, 3).Value = "---" Target.Offset(0, 4).Select Else: End If End Sub Any help?? |
can I use an update macro on multiple columns
Works excellently...thanks
"Tom Ogilvy" wrote: Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("F:F,J:J,M:M")) Is Nothing Then Exit Sub Application.EnableEvents = False Target.Offset(0, 1).Value = Date Target.Offset(0, 2).Value = Environ("UserName") Application.EnableEvents = True If Intersect(Target, Range("F:F,J:J,M:M")) = "Complete" Then Target.Offset(0, 3).Value = "---" Target.Offset(0, 4).Select Else: End If End Sub -- Regards, Tom Ogilvy "Shahid" wrote: Hello, Am using the following code to run a macro after I update a cell within a column..It works fine on one column (F:F)..but I wanted it to do the same thing on multiple columns J:J, M:M, etc.... 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 Target.Offset(0, 2).Value = Environ("UserName") Application.EnableEvents = True If Intersect(Target, Range("F:F")) = "Complete" Then Target.Offset(0, 3).Value = "---" Target.Offset(0, 4).Select Else: End If End Sub Any help?? |
All times are GMT +1. The time now is 05:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com