PC Review


Reply
Thread Tools Rate Thread

Activating macro by leaving a spreadsheet

 
 
caraj@cox.net
Guest
Posts: n/a
 
      14th Jan 2007
I wrote a routine Sub In2Out( )

To activate In2Out( ) I have to go to tools, macro, run or assign a
cntrl + key.
I wish the macro to execute when I deactivate worksheet IN (The
workbook has 2 worksheets IN and OUT).
The event App_SheetDeactivate does what I want but it requires a right
click on the worksheet tab - an extra key click.
So I'm back to needing a way to execute the macro by deactivating work
sheet IN.

Thanks ahead of time,
John

 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      14th Jan 2007
Use the following in the ThisWorkbook code module:


Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
If StrComp(Sh.Name, "IN", vbTextCompare) = 0 Then
''''''''''''''''''''''''''''''''''''''''''''''
' Sheet "In" is being deactivated.
' Your code here.
''''''''''''''''''''''''''''''''''''''''''''''
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I wrote a routine Sub In2Out( )
>
> To activate In2Out( ) I have to go to tools, macro, run or assign a
> cntrl + key.
> I wish the macro to execute when I deactivate worksheet IN (The
> workbook has 2 worksheets IN and OUT).
> The event App_SheetDeactivate does what I want but it requires a right
> click on the worksheet tab - an extra key click.
> So I'm back to needing a way to execute the macro by deactivating work
> sheet IN.
>
> Thanks ahead of time,
> John
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen Saver not activating after leaving only !! =?Utf-8?B?THlubg==?= Windows XP General 6 8th Jun 2007 10:11 PM
Can a macro be made to run on entering or leaving a cell? =?Utf-8?B?RGF2ZSBMaXN0ZXI=?= Microsoft Excel Misc 1 3rd Dec 2005 07:11 PM
Saving Multiple Sheets to Another Spreadsheet Without Leaving the Initial Workbook Carroll Microsoft Excel Programming 4 21st Jun 2005 06:06 PM
Kick off a Macro upon leaving a cell? =?Utf-8?B?TXIgQg==?= Microsoft Excel Misc 1 18th Mar 2004 03:06 PM
Copy one spreadsheet into another without activating second spreadsheet's user form P Cheek Microsoft Excel Programming 3 23rd Jul 2003 06:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:44 PM.