Need to write 2 worksheet change events on 1

August 15, 2011 at 10:35:51
Specs: Windows 7, 1GB
I have the following macros which I want to run whenever certain cells change as follows:

1. Condition 1/Macro 1:

Private Sub Worksheet_Change(ByVal Target As Range)
'
'
If Intersect(Target, Range("critical_date")) Is Nothing Then
Exit Sub
Else
Call Module1.generate_ref_no
End If

End Sub

Macro 2,
I want to tell the computer to run a macro that goes to cell A8, worksheet, "Shearwater Input", each time there is a change in cells (J9, J10....J22) to "SWA_P".

Both change event macros are in a sheet called "Input".


See More: Need to write 2 worksheet change events on 1

Report •

#1
August 15, 2011 at 13:00:58
You can only have one Worksheet_Change macro per sheet, but that one macro can handle multiple conditions.

Just use a If-Then section for each range that you want to work with.


Private Sub Worksheet_Change(ByVal Target As Range)

'Condition 1

    If Not Intersect(Target, Range("critical_date")) Is Nothing Then
      'Do whatever you need if the Target is within "critical_date"
    End If

'Condition 2

     If Not Intersect(Target, Range("J9:J22")) Is Nothing Then
      'Do whatever you need if the Target is within J9:J22
    End If

'Condition 3

    etc.


End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •
Related Solutions


Ask Question