Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Before Worksheet Close

Is there a way to run a particular macro when focus is change from a
particular worksheet to any other worksheet by selecting another worksheet?

Thanks for your help.

Jim Walsh
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Before Worksheet Close

Private Sub Worksheet_Deactivate()
....your code
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
__________________________________
HTH

Bob

"jswalsh33" wrote in message
...
Is there a way to run a particular macro when focus is change from a
particular worksheet to any other worksheet by selecting another
worksheet?

Thanks for your help.

Jim Walsh



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Before Worksheet Close

DeActivate event is triggered when you select another worksheet..

Private Sub Worksheet_Deactivate()
MsgBox "ok"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"jswalsh33" wrote:

Is there a way to run a particular macro when focus is change from a
particular worksheet to any other worksheet by selecting another worksheet?

Thanks for your help.

Jim Walsh

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Before Worksheet Close

If the two worksheets are in separate workbooks, you may want to use the
workbook event:
Private Sub Workbook_Deactivate()

(maybe both????)

jswalsh33 wrote:

Is there a way to run a particular macro when focus is change from a
particular worksheet to any other worksheet by selecting another worksheet?

Thanks for your help.

Jim Walsh


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Before Worksheet Close

Bob,

That works good, but it allows the newly selected worksheet to be activated
before the the Deactivate code operates. I tried putting in
"Application.ScreenUpdating = False" as the first line of code but that did
not prevent it. Is there a way to keep the screen from switching to the newly
selected worksheets?

Thanks Again,

Jim Walsh

"Bob Phillips" wrote:

Private Sub Worksheet_Deactivate()
....your code
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
__________________________________
HTH

Bob

"jswalsh33" wrote in message
...
Is there a way to run a particular macro when focus is change from a
particular worksheet to any other worksheet by selecting another
worksheet?

Thanks for your help.

Jim Walsh






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Before Worksheet Close

I can't see it because that sheet is not deactivated until something else is
activated.

--
__________________________________
HTH

Bob

"jswalsh33" wrote in message
...
Bob,

That works good, but it allows the newly selected worksheet to be
activated
before the the Deactivate code operates. I tried putting in
"Application.ScreenUpdating = False" as the first line of code but that
did
not prevent it. Is there a way to keep the screen from switching to the
newly
selected worksheets?

Thanks Again,

Jim Walsh

"Bob Phillips" wrote:

Private Sub Worksheet_Deactivate()
....your code
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
__________________________________
HTH

Bob

"jswalsh33" wrote in message
...
Is there a way to run a particular macro when focus is change from a
particular worksheet to any other worksheet by selecting another
worksheet?

Thanks for your help.

Jim Walsh






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
Create new workbook and new worksheet and close. Worksheet not saved Patrick Molloy Excel Programming 0 July 25th 09 07:00 PM
Create new workbook and new worksheet and close. Worksheet not sav Patrick Djo Excel Programming 0 July 21st 09 02:19 PM
Create new workbook and new worksheet and close. Worksheet not sav Patrick Djo Excel Worksheet Functions 0 July 20th 09 07:10 PM
Copy & paste cells fr open worksheet then close the worksheet Sin Excel Programming 1 October 2nd 06 02:20 PM
How to sum value from master worksheet taking value from other close worksheet nuha1578 Excel Programming 1 November 3rd 03 02:58 PM


All times are GMT +1. The time now is 02:14 PM.

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

About Us

"It's about Microsoft Excel"