Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm sure this is an easy question. I already have a
Worksheet_Change(ByVal Target as Range) procedure for my "Sales" worksheet. I need to add code to respond to some additional changes on the sheet. How is that done? (I added the code in the same procedure, but it doesn't work.) Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use Else, like this
Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range("H1:H10")) Is Nothing Then With Target 'do your stuff End With ElseIf Not Intersect(Target, Me.Range("M5:M15")) Is Nothing Then With Target 'do your stuff End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH RP (remove nothere from the email address if mailing direct) "JG Scott" wrote in message ups.com... I'm sure this is an easy question. I already have a Worksheet_Change(ByVal Target as Range) procedure for my "Sales" worksheet. I need to add code to respond to some additional changes on the sheet. How is that done? (I added the code in the same procedure, but it doesn't work.) Thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Add the code in the same procedure in a case statement as one way.
Private Sub Worksheet_Change(ByVal Target As Range) Select Case Target.Address(0,0) Case "A1" ' action to take if A1 is change Case "B9","C5" ' action to take if B9 or C5 is changed Case "F2" ' action to take if F2 is changed End Select End Sub -- Regards, Tom Ogilvy "JG Scott" wrote in message ups.com... I'm sure this is an easy question. I already have a Worksheet_Change(ByVal Target as Range) procedure for my "Sales" worksheet. I need to add code to respond to some additional changes on the sheet. How is that done? (I added the code in the same procedure, but it doesn't work.) Thanks. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks. Very helpful.
|
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Bob...I was having the same issue with two change events and your
ELSEIF on the 2nd event got me what I needed! Thanks much! "Bob Phillips" wrote: Use Else, like this Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range("H1:H10")) Is Nothing Then With Target 'do your stuff End With ElseIf Not Intersect(Target, Me.Range("M5:M15")) Is Nothing Then With Target 'do your stuff End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH RP (remove nothere from the email address if mailing direct) "JG Scott" wrote in message ups.com... I'm sure this is an easy question. I already have a Worksheet_Change(ByVal Target as Range) procedure for my "Sales" worksheet. I need to add code to respond to some additional changes on the sheet. How is that done? (I added the code in the same procedure, but it doesn't work.) Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Combine 2 worksheet change events | Excel Discussion (Misc queries) | |||
Cell change events | Excel Discussion (Misc queries) | |||
Change events and linked cells | Excel Programming | |||
msg box and or sheet events | Excel Programming | |||
Excel 97 - Inconsistent Change Events | Excel Programming |