View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JMay JMay is offline
external usenet poster
 
Posts: 422
Default Trying to Understand Worksheet_Change Event

From all my (12) excel books I'm unable to clearly
grasp this idea of how one needs to include the

Application.EnableEvents = False code line at times when
an infinite-loop is triggered...

Below I've set up the following example (trying to better understand):

Private Sub Worksheet_Change(ByVal Target As Range)
Range("D4").Value = Range("D1") + 100 'Cell D1 is formula =B7
If Range("D4").Value 1000 Then
MsgBox "Your entry produces an amt greater than 1000"
Range("D4").Value = 999
End If
End Sub

While view all 3 windows (the Code window, the spreadsheet and the
immediate)
In the immediate-window I enter:

Range("B7").Value = 2800 << And press enter

The problem? There doesn't seem to be one. LOL

Can someone show me by telling me what I need to
change here in order to get the infinite-loop
that is warned about (where the EnableEvents = False
nullifys the problem)..

TIA,
JMay