Hide Userform Unless On "Home" page

RLPeloquin

Board Regular
Joined
Jul 4, 2020
Messages
73
Office Version
  1. 2019
Platform
  1. Windows
Even with this code It still does not always hide Userform1 when I'm on other sheets. Is there another code to absolutely hide Userform1 when I'm not on the "Home" Page

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If ActiveSheet <> ("Home") Then
UserForm1.Hide
End If
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try this:
VBA Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
'Modified  5/10/2021  4:07:51 PM  EDT
If ActiveSheet.Name <> "Home" Then UserForm1.Hide
End Sub
 
Upvote 0
If you want to show the Userform automatically every time you activate sheet named "Home"
But hide it when you activate another sheet try this:
VBA Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
'Modified  5/10/2021  4:26:51 PM  EDT

Select Case ActiveSheet.Name
    Case "Home"
        UserForm1.Show modeless
Case Else
    UserForm1.Hide
End Select
End Sub
 
Upvote 0
Solution
If you want to show the Userform automatically every time you activate sheet named "Home"
But hide it when you activate another sheet try this:
VBA Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
'Modified  5/10/2021  4:26:51 PM  EDT

Select Case ActiveSheet.Name
    Case "Home"
        UserForm1.Show modeless
Case Else
    UserForm1.Hide
End Select
End Sub
Thanks! Works Perfect
 
Upvote 0

Forum statistics

Threads
1,214,416
Messages
6,119,386
Members
448,891
Latest member
tpierce

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