A ameyabrid New Member Oct 20, 2011 #1 Hello Everyone, I was wondering if it is possible to include two (2) separate actions in the worksheet_change event.
Hello Everyone, I was wondering if it is possible to include two (2) separate actions in the worksheet_change event.
Hui Excel Ninja Staff member Oct 20, 2011 #2 Ameyabrid Firstly, Welcome to the Chandoo.org Forums When you say 2 separate actions, the Worksheet Change event occurs when there is any change on the worksheet. You can code inside the associated subroutine to check for any number of conditions eg if A1=1 and D20=10 then do something otherwise exit if the change cell is within a range do something etc One a Change event is triggered you can do anything or any number of activities within the code.
Ameyabrid Firstly, Welcome to the Chandoo.org Forums When you say 2 separate actions, the Worksheet Change event occurs when there is any change on the worksheet. You can code inside the associated subroutine to check for any number of conditions eg if A1=1 and D20=10 then do something otherwise exit if the change cell is within a range do something etc One a Change event is triggered you can do anything or any number of activities within the code.
A ameyabrid New Member Oct 20, 2011 #3 Thanks for replying Hui, I apologize for not being clear and specific about my requirements earlier. Here's a brief overview of what I would like to achieve: If a cell in column P changes, do Action 1 If a cell in column L changes, do Action 2 I've made two separate subs for Actions 1 & 2 and I'm calling them in the worksheet_change event like this: [/code] Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("L6:L5000")) Is Nothing Then Call Assignment ElseIf Not Intersect(Target, Range("P65000")) Is Nothing Then Call StatusUpdate Else End If End Sub [/code] I am getting a compile error in the line 'Call Assignment' and it says Argument not optional. Any thoughts??
Thanks for replying Hui, I apologize for not being clear and specific about my requirements earlier. Here's a brief overview of what I would like to achieve: If a cell in column P changes, do Action 1 If a cell in column L changes, do Action 2 I've made two separate subs for Actions 1 & 2 and I'm calling them in the worksheet_change event like this: [/code] Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("L6:L5000")) Is Nothing Then Call Assignment ElseIf Not Intersect(Target, Range("P65000")) Is Nothing Then Call StatusUpdate Else End If End Sub [/code] I am getting a compile error in the line 'Call Assignment' and it says Argument not optional. Any thoughts??
A ameyabrid New Member Oct 20, 2011 #4 I think I figured it out. I had included (ByVal Target As Range) in the sub headers for the "Assignment" and "StatusUpdate" routines which wasn't required. Thanks for your help Hui. I really appreaciate it.
I think I figured it out. I had included (ByVal Target As Range) in the sub headers for the "Assignment" and "StatusUpdate" routines which wasn't required. Thanks for your help Hui. I really appreaciate it.