+ Reply to Thread
Results 1 to 6 of 6

use "Workbook_SheetDeactivate(ByVal Sh As Object)"

Hybrid View

  1. #1
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: use "Workbook_SheetDeactivate(ByVal Sh As Object)"

    Code in Thisworkbook module

    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    
        If g_objLastSheet Is Nothing Then Exit Sub
    
        Set g_objLastSheet = Sh
        
    End Sub
    Standard code module
    Sub MoveBack()
    
    Debug.Print "Before", ActiveSheet.Name, g_objLastSheet.Name
        g_objLastSheet.Activate
    Debug.Print "After", ActiveSheet.Name, g_objLastSheet.Name
        
    End Sub
    No idea how you are using it though
    Cheers
    Andy
    www.andypope.info

  2. #2
    Registered User
    Join Date
    11-06-2013
    Location
    Israel
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: use "Workbook_SheetDeactivate(ByVal Sh As Object)"

    Quote Originally Posted by Andy Pope View Post
    Code in Thisworkbook module

    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    
        If g_objLastSheet Is Nothing Then Exit Sub
    
        Set g_objLastSheet = Sh
        
    End Sub
    Standard code module
    Sub MoveBack()
    
    Debug.Print "Before", ActiveSheet.Name, g_objLastSheet.Name
        g_objLastSheet.Activate
    Debug.Print "After", ActiveSheet.Name, g_objLastSheet.Name
        
    End Sub
    No idea how you are using it though
    thank you.
    when running the Moveback() , I'm getting a runtime error '424' object required..
    any ideas?

+ 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. Need help creating VBA looping code in "Worksheet_Change(ByVal Target As Range)"
    By jimredfield in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-11-2012, 03:09 PM
  2. "The "sheets" method from the "_Global" object have failed."
    By mankit87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2011, 08:53 AM
  3. Error msgs: "Object varible or with block variable not set"; "subscript out of range"
    By menyanthe in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-26-2009, 04:58 PM
  4. 2 target cells for "Change(ByVal..." worksheet macro
    By timmtamm in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-12-2009, 05:12 PM
  5. What is Error "Method "Paste" of object "_Worksheet" failed?
    By vat in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-17-2006, 04:10 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