Activating macro by leaving a spreadsheet

C

caraj

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
 
C

Chip Pearson

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top