Workbook Deactivate event

raymondcidad

New Member
Joined
Aug 13, 2008
Messages
2
I´m trying to deactivate or hide some controls in excel with a vb code.
I hide the controls when some sheets are activate with the code:


Code:
Private Sub Worksheet_Activate()
'some code. works fine
end sub 
and then unhide the controls again with the code


Code:
Private Sub Worksheet_Deactivate()
'some code. works fine.
end sub

The problems is that if the sheet is not deactivate, but is the workbook that is deactivate, for example if I change to another workbook, the second code is never run and the controls remain on hide mode.
Im trying to run some code when I change to another woorkbook.
I tried to put the code in the App_WorkbookDeactivate() sub, but that subrutine doesn't run when I change to another workbook.

Code:
Private Sub App_WorkbookDeactivate()
'Code never run!
end sub

I also tried
App_WorkbookDeactivate(ByVal Wb As Workbook)
and
Workbook_Deactivate()

I´m placing this code in the sheet code.

Any ideas?
thanks!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
The correct events are
Workbook_Activate()
and
Workbook_deactivate()

The event code must exist in the ThisWorkbook module of your VBA project for them to work.

HTH
Cal
 
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,366
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top