Hide Inactive Workbooks Through VBA

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

 

img1

 

  • 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

 

img2

 

  • 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

 

img3

 

  • This will show the unhide workbooks

 

img4

 

  • 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.

 

image 48 

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 info@exceltip.com

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.