can I use an update macro on multiple columns

G

Guest

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??
 
G

Guest

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
 
G

Guest

Works excellently...thanks

Tom Ogilvy said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top