+ Reply to Thread
Results 1 to 5 of 5

"Private Sub Worksheet_Deactivate()" doesn't trigger

  1. #1
    Registered User
    Join Date
    11-01-2013
    Location
    Essex UK
    MS-Off Ver
    Excel 2003
    Posts
    95

    "Private Sub Worksheet_Deactivate()" doesn't trigger

    I'm using Excel 2003 on Windows 10.
    I'm trying to use:-

    "Private Sub Worksheet_Deactivate()"
    "Userform1.Hide"
    "End Sub"......

    ....placed in the code area of the worksheet,
    to dismiss a Userform from that Worksheet,
    when I leave it by selecting another Worksheet's tab.
    It doesn't trigger.
    If I run the code manually, it works.
    There are no "Application.EnableEvents=true or false" lines in the code.

    I'm curious to know what can be stopping the code from triggering.

    If I write a simple, separate, stand alone programme to do the same thing, it works fine.
    So presumably there's so presumably, there's something in my code causing the problem,
    but I don't know what to look for.

    In the wider world of Excel, there must be some known quirks that can cause this behaviour?
    Help please

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: "Private Sub Worksheet_Deactivate()" doesn't trigger

    It might be the case that the userform has the focus when you activate the other sheet.
    A workaround might be to use the Workbook level SheetActivate event and test for the key worksheet.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: "Private Sub Worksheet_Deactivate()" doesn't trigger

    Do you have any conditional formatting that uses UDFs?
    Rory

  4. #4
    Registered User
    Join Date
    11-01-2013
    Location
    Essex UK
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: "Private Sub Worksheet_Deactivate()" doesn't trigger

    I did have a module in the workbook with conditional formatting, but it's removal had no effect - still no triggering

  5. #5
    Registered User
    Join Date
    11-01-2013
    Location
    Essex UK
    MS-Off Ver
    Excel 2003
    Posts
    95

    Re: "Private Sub Worksheet_Deactivate()" doesn't trigger

    Hi MikeRickson
    I tried your suggestion of using a Workbook level SheetActivate event, but again there is no trigger.
    I did try a simple programme with the basics of what I'm trying to do and that worked fine.
    If I MANUALLY step through the code I'm trying to trigger in the problem Workbook , it works fine.
    So it seems as if there's some setting in my code that's inhibiting the trigger event.
    Still baffled !

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.
    By H.Gabor in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 07-26-2018, 06:36 AM
  2. [SOLVED] Copy values from sheet"list" to "invoce" on trigger
    By perko121 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-11-2017, 11:33 AM
  3. [SOLVED] "IF" formula should return "yes" according to evaluation tool but doesn't
    By bkwins in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-05-2015, 09:15 PM
  4. Why IF(VLOOKUP(A1,B:B,1,0)=A1,"1","0") doesn't work properly?
    By regresss in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-30-2015, 06:18 PM
  5. [SOLVED] Pasting values between ranges in different workbooks: "Range" works but "Cells" doesn't
    By Flaubert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-13-2013, 01:19 PM
  6. Open files from FTP server (works with "servername" but doesn't work with "ip address")
    By adammsu1983 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2012, 04:30 PM
  7. [SOLVED] Why doesn't "private" work?
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-13-2006, 05:20 PM

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