+ Reply to Thread
Results 1 to 2 of 2

Application.EnableEvents

Hybrid View

  1. #1
    Registered User
    Join Date
    07-05-2007
    Location
    Cincinnati, OH
    Posts
    44

    Application.EnableEvents

    Hello

    Please look at my code below. Can you tell me if my "Application.EnableEvents" command is placed correctly? The code is much longer than below, with other If's pertaining to other ranges being intersected. The macros I've created work, but only for a couple times. I feel that this may be the culprit. If you have another suggestion, please let me know. I have 5 sheets in a workbook, and 3 of them have Worksheet_Change functions - and those are based off of different ranges.

    Thank you!

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim BidEntry As Variant
        Dim OrdEntry As Variant
        Dim Swbds As Variant
        Dim ProdInfo As Variant
    
    If Intersect(Target, Range("SelectBid")) Is Nothing Then
            
            Else
            
                Select Case Target.Value
               
                    Case Is = "X", "x" 'user enter X... copy info to Orders Selected sheet
                        Application.EnableEvents = False
                        Target = "X" 'makes any lower case to upper one
                        BidEntry = ""
                        BidEntry = Target.Offset(0, -3).Range("A1:C1")
                        Run "AddToBidList", BidEntry
                        Application.EnableEvents = True
                        Target.Offset(1, 0).Activate ' move active cell down
                
                   Case Else
                        Run "Find_and_deleteBid", Target.Offset(0, -3) 'check if job exist in orders selected. if so, deletes it
                        Application.EnableEvents = False 'this disable any macro that is trigger any other auto-macro
                        Target = ""
                        Application.EnableEvents = True
                    End Select
                    
                
                    
               End If
    End Sub

  2. #2
    Registered User
    Join Date
    07-05-2007
    Location
    Cincinnati, OH
    Posts
    44
    I solved my own problem!

    "Find_and_DeleteBid" triggers another auto macro, so now my code looks like this:

    Case Else
     Application.EnableEvents = False 'this disable any macro that is trigger any other auto-macro
                        Run "Find_and_deleteBid", Target.Offset(0, -3) 'check if job exist in orders selected. if so, deletes it
                          Target = ""
                        Application.EnableEvents = True
                    End Select

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1