View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default EnableEvent On Change

Events got disabled because of a slight logic problem.

To start them run this macro:

Sub StartEvents()
Appliction.EnableEvents = True
End Sub

fix the code to look like this:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Goto ws_err
Application.EnableEvents = False
If Not Intersect(Target, Range("D5:G10")) Is Nothing Then
Target.Value = Target.Value * 1.06
End If
ws_err:
Application.EnableEvents = True
End Sub


--
Regards,
Tom Ogilvy

"Jim May" wrote in message
news:RB5Yd.58764$%U2.37993@lakeread01...
Bob:
Thanks;
What logic am I missing here? After EVERY - CHANGE this Macros runs,

right?
So what stops it dead (from further calculating) when I enter 100 in cell
D6?
Jim

"Bob Phillips" wrote in message
...
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Goto ws_err
Application.EnableEvents = False
If Intersect(Target, Range("D5:G10")) Is Nothing Then
Exit Sub
Else
Target.Value = Target.Value * 1.06
End If

ws_err:
Application.EnableEvents = True
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jim May" wrote in message
news:Sj5Yd.58600$%U2.51909@lakeread01...
It's obvious i haven't understood this situation where a change,

causes
a
change, which causes a change -- of course this is happening due to

my
line:
Target.Value = Target.Value * 1.06
If I enter 100 in cell D6 - the system goes wild and produces

102,461.64
versus my expected 106.
Help with this would be appreciated.
TIA,

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("D5:G10")) Is Nothing Then
Exit Sub
Else
Target.Value = Target.Value * 1.06
End If
End Sub