View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 2,069
Default More then 1 worksheet_change event

As mike already stated, worksheet change event for each sheet.
Is this approach something like what you are trying to do?

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False

If Not Application.Intersect(Target, Me.Range("B1")) Is Nothing Then

If LCase(Me.Range("B1").Value) = "on" Then

Me.Shapes("Autoshape 5").Visible = True

Me.Range("A12").Value = "Please go to the next Question"

Else

Me.Shapes("Autoshape 5").Visible = False

Me.Range("A12").Value = ""

End If

ElseIf Not Application.Intersect(Target, Me.Range("C1")) Is Nothing Then



'do more stuff

ElseIf Not Application.Intersect(Target, Me.Range("D1")) Is Nothing Then

'do more stuff
End If


Application.EnableEvents = True

End Sub
--
jb


"John" wrote:

Hi
I'm just starting to work with VBA and below are my codes.
I would need several routine like this one on the same worksheet but VBE won't
let me ( Can't have more than 1 worksheet_change ).
Can anyone help me ?

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False

If Not Application.Intersect(Target, Range("B1")) Is Nothing Then
If Range("B1") = "on" Then Me.Shapes("Autoshape 5").Visible = True
If Range("B1") = "off" Then Me.Shapes("Autoshape 5").Visible = False
End If
If Range("B1") = "on" Then
Range("A12").Value = "Please go to the next Question"
End If
If Range("B1") = "off" Then
Range("A12").Value = ""
Range("B1").Value = ""
End If

Range("B1").Select
Application.EnableEvents = True
End Sub

Best regards
John