Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Application.EnableEvents help

Tom,

I thought it was working, but it's not. Do you know what would cause the
below code to run when it should if cell B5 was the target, but if I only
change the target cell to E5, it runs even if Range("AA5").Value = "". It
only runs once though and at the end I get an error box, "application defined
or object define error?" Thanks.

On Error goto ErrHandler

If Target.Address = "$B$5" And Range("AA5").Value < "" Then
Application.EnableEvents = False
Call Input_FieldsNoPartNumber
End If

ErrHandler:
Application.EnableEvent = True

End Sub




"Tom Ogilvy" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

On Error goto ErrHandler

If Target.Address = "$B$5" And Range("AA5").Value < "" Then
Application.EnableEvents = False
Call Input_FieldsNoPartNumber
Elseif Target.Address = "$E$5" And Range("AA5").Value < "" Then
Application.EnableEvents = False
Call Input_FieldsNoChangeLevel
End If

ErrHandler:
Application.EnableEvent = True

End Sub

Would be my suggestion.

the procedures shouldn't be called unless you make a change in B5 or E5.


--
Regards,
Tom Ogilvy



"Alex" wrote:

When a user first opens a template worksheet he clicks a button which runs a
macro containing unput boxes for him to input information. If, during the
course of filling out the worksheet, he changes the value in cell B5 or cel
E5 I need the input boxes to run again. In order to keep the first input
boxes from running continually, I know I need Application.EnableEvents in the
worksheet_change code. I can't get the worksheet_change code to work
properly, however. The initial input boxes either run continually or the
macros listed below don't run at all when B5 or E5 change. Can someone help
me fix the below code. Thanks.

fyi - I have 3 modules. The first one runs all input boxes. The one
referenced below called input_fieldsNoPartNumber runs all input boxes but the
partnumber box, which initially populates cell B5 and the module called
input_fieldsnochangelevel runs all input boxes except the change level field,
which initially populates cell E5.

code below is one of the many variations I've tried.

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$B$5" And Range("AA5").Value < "" Then
Application.EnableEvents = False
Call Input_FieldsNoPartNumber
'Application.EnableEvents = True
End If
'Exit Sub

If Target.Address = "$E$5" And Range("AA5").Value < "" Then
Application.EnableEvents = False
Call Input_FieldsNoChangeLevel
Application.EnableEvents = True
'Exit Sub
End If

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.EnableEvents DCPan Excel Worksheet Functions 3 October 18th 08 05:46 AM
Application.EnableEvents ... Is Local or Global ? monir Excel Programming 11 September 22nd 06 05:58 PM
application.EnableEvents nc Excel Discussion (Misc queries) 1 September 28th 05 04:00 PM
application.enableEvents jeffP Excel Programming 1 August 1st 04 03:12 PM
Application.EnableEvents Terry Excel Programming 2 April 2nd 04 08:25 PM


All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"