If you are working on multiple workbooks at the same time, and you need a macro to help you in hiding all the inactive workbooks, then this article will definitely help you.
In this article, we will focus on how we can hide multiple workbooks which you are currently not being used.
Question: I need to quickly hide all the excel files except the one I am currently using so that I can toggle between other applications smoothly. I would like to seek VBA code for this unique requirement of mine.
In order to get the code for hiding all the inactive workbooks, we need to follow the below steps to launch VB editor
- Click on Developer tab
- From Code group select Visual Basic
- Copy the following code in worksheet module
Sub HideInactiveExcelWorkbooks() Application.ScreenUpdating = False Dim aWin As Window Set aWin = ActiveWindow Dim win As Window For Each win In Application.Windows win.Visible = False Next win aWin.Visible = True Application.ScreenUpdating = True End Sub
- The above code will hide all the inactive workbooks immediately
Note: the above macro will not hide active workbook.
To unhide all the workbooks, we need to follow the below steps:
- Click on View tab
- Click on Unhide
- This will show the unhide workbooks
- Selecting each one & clicking on Ok button will unhide the workbook
Conclusion: We can hide hundreds of workbooks which are not active with a single click using above macro code.
If you liked our blogs, share it with your friends on Facebook. And also you can follow us on Twitter and Facebook.
We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write us at firstname.lastname@example.org