ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet Deactivate (https://www.excelbanter.com/excel-programming/335881-worksheet-deactivate.html)

Graham Haughs

Worksheet Deactivate
 
I am trying to enter code in a worksheet so that when I move to another
worksheet, several columns are hidden in the original worksheet, so that
when I return to it they are hidden. This is the code I am using but
keep getting a de-bug message.

Private Sub Worksheet_Deactivate()
ActiveSheet.Unprotect
Columns("O:Z").EntireColumn.Hidden = True
ActiveSheet.Protect
End Sub

I am sure it probably has something to do with the term Activesheet but
I don't know how to get round it.
I would appreciate any help.

Kind Regards
Graham Haughs
Turriff, Scotland

Bob Phillips[_6_]

Worksheet Deactivate
 
Are you thinking activesheet is the sheet you are coming from or the one you
are going to?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Graham Haughs" wrote in message
...
I am trying to enter code in a worksheet so that when I move to another
worksheet, several columns are hidden in the original worksheet, so that
when I return to it they are hidden. This is the code I am using but
keep getting a de-bug message.

Private Sub Worksheet_Deactivate()
ActiveSheet.Unprotect
Columns("O:Z").EntireColumn.Hidden = True
ActiveSheet.Protect
End Sub

I am sure it probably has something to do with the term Activesheet but
I don't know how to get round it.
I would appreciate any help.

Kind Regards
Graham Haughs
Turriff, Scotland




Graham Haughs

Worksheet Deactivate
 
Bob Phillips wrote:
Are you thinking activesheet is the sheet you are coming from or the one you
are going to?

The activesheet is the one I am leaving.
Graham


Bob Phillips[_7_]

Worksheet Deactivate
 
If you use the Workbook_SheetDeactivate workbook event, sh gives you the
sheet you are leaving.

--
HTH

Bob Phillips

"Graham Haughs" wrote in message
...
Bob Phillips wrote:
Are you thinking activesheet is the sheet you are coming from or the one

you
are going to?

The activesheet is the one I am leaving.
Graham




Graham Haughs

Worksheet Deactivate
 
Bob Phillips wrote:
If you use the Workbook_SheetDeactivate workbook event, sh gives you the
sheet you are leaving.


Thanks for that Bob

Graham


All times are GMT +1. The time now is 07:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com