Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Activating macro by leaving a spreadsheet

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Activating macro by leaving a spreadsheet

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)

wrote in message
ups.com...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Activating a Macro d_kight New Users to Excel 5 June 30th 06 07:46 PM
sort macro that works after leaving worksheet garyablett Excel Discussion (Misc queries) 1 May 5th 06 07:07 AM
Can a macro be made to run on entering or leaving a cell? Dave Lister Excel Discussion (Misc queries) 1 December 3rd 05 07:11 PM
Saving Multiple Sheets to Another Spreadsheet Without Leaving the Initial Workbook Carroll[_2_] Excel Programming 4 June 21st 05 06:06 PM
Copy one spreadsheet into another without activating second spreadsheet's user form P Cheek Excel Programming 3 July 23rd 03 06:26 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"