UserForm QueryClose to hide sheets

drag1c

Board Regular
Joined
Aug 7, 2019
Messages
92
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Hi,
I am trying to make macro which will hide specific sheets when UserForm is closed. Unfortunately UserForm_QueryClose does not allow me to hide them --> They always popup.
I've been using next macroes:
Module1:
Code:
Sub Show_Form()
frmForm.Show
Sheet2.Visible = xlSheetVisible
Sheet5.Visible = xlSheetVisible
Sheet9.Visible = xlSheetVisible
End Sub

frmForm
Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Sheet2.Visible = xlSheetVeryHidden
Sheet5.Visible = xlSheetVeryHidden
Sheet9.Visible = xlSheetVeryHidden
End Sub

Reason why I hide sheets is that form put values inside, so they have to be visible while form is open. Otherwise, they have to be hidden from user.
What could be a problem?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Sorry for spam, I've found solution and it's below:
frmForm
Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Sheet2.Visible = xlSheetVeryHidden
Sheet5.Visible = xlSheetVeryHidden
Sheet9.Visible = xlSheetVeryHidden
End Sub

Private Sub UserForm_Activate()
    Sheets("Database").Visible = xlSheetVisible
    Sheets("DB_Log").Visible = xlSheetVisible
    Sheets("Database_Copy").Visible = xlSheetVisible
End Sub

Delete visibility rows from Sub Show_Form().
 
Upvote 0
Solution

Forum statistics

Threads
1,215,670
Messages
6,126,127
Members
449,293
Latest member
yallaire64

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