+ Reply to Thread
Results 1 to 2 of 2

How to trap the worksheet_BeforeDeactivate event?

  1. #1
    OKLover
    Guest

    How to trap the worksheet_BeforeDeactivate event?

    The worksheet_deactivate event works like worksheet_afterdeactivate event.
    How do i trap the worksheet_beforeDeactivate event?

  2. #2
    Bob Phillips
    Guest

    Re: How to trap the worksheet_BeforeDeactivate event?

    It actually depends upon what you want to do. When Deactivate fires, the
    active sheet is the new target sheet, but the Sh argument still points at
    the old one, so you can do something like

    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    Dim this As Worksheet
    On Error GoTo wb_exit
    Application.EnableEvents = False
    Set this = ActiveSheet
    Sh.Activate
    'do your stuff
    this.Activate
    wb_exit:
    Application.EnableEvents = True
    End Sub

    --

    HTH

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


    "OKLover" <[email protected]> wrote in message
    news:[email protected]...
    > The worksheet_deactivate event works like worksheet_afterdeactivate event.
    > How do i trap the worksheet_beforeDeactivate event?




+ 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