Hide Sheet once you have moved away from it

Ben_Holmes

Board Regular
Joined
Mar 30, 2004
Messages
147
Hi,

Does anyone happen to have any code that would ensure that a sheet is hidden when a user moves away from it?

I.e. they click onto another sheet?

Kind Regards

Ben
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Try this: right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Deactivate()
Me.Visible = xlSheetHidden
End Sub
 
Upvote 0
I have tried that but can not get it to work have I got it in the correct place?

Sub Quotetool()
'
' Turns off screenupdating (Makes screen transition more smooth)
Application.ScreenUpdating = False

' Selects cell to check (Change this to whatever cell is relevant)
Range("R20").Select

' If statement (Change rule to whatever you want, if could also be a cell reference)
If ActiveCell >= 0.18 Then

' Actions if true
Sheets("Quote Tool").Visible = True
Sheets("Quote Tool").Select
Range("A1").Select

' Actions if false
Else
MsgBox ("Insufficient revenue")

' Ends if
End If

' Turns screenupdating back on
Application.ScreenUpdating = True

End Sub

' Turns sheet hidden once move away from it
Private Sub Worksheet_Deactivate()
Me.Visible = xlSheetHidden
 
Upvote 0
No, it should go in the sheet's code module. Right click the sheet tab, select View Code and paste in the code.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,877
Members
452,949
Latest member
Dupuhini

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