I usually have multiple workbooks open and on one workbook, I have a VBA code that hides the workbook and shows a UserForm. But when I open that workbook, all of my workbooks that are currently opened will also hide. What code can I use to just hide 1 workbook?
Here are the codes I've tried:
ThisWorkbook.Application.Visible = False Windows(ThisWorkbook.name).Visible = False Application.Windows(1).visible = false
Windows(ThisWorkBook.name).visible = False works with closing only one workbook, it messes with the workbook and the sheets don't show at all. I can't even close the excel workbook without using the task manager.
ThisWorkbook.Application.Visible = False will change the
Visible property of the <strong>application</strong> running your workbook, i.e. an instance of Excel.EXE ... if this instance is running your other books, too, then as a consequence all these books will disappear from screen.
To hide a single workbook, use
ActiveWindow.Visible = False
or alternatively, if the workbook you want to hide (e.g. "MyWorkbook") is not the active one
Windows("MyWorkbook").Visible = False
Pay attention that hiding a window also moves the pointer to the ActiveSheet, likewise when you reverse this (i.e.
...Visible = True) the displayed sheet becomes active.