How To Dynamically Hide Or Unhide Multiple Tabs Using VBA in Excel?
Tags: todynamicallyhideoru, vbamacros
Published: 2021-09-23 06:41:49

---
title: How To Dynamically Hide Or Unhide Multiple Tabs Using VBA in Excel?
published: true
date: 2021-09-23 02:15:39 UTC
tags: ToDynamicallyHideOrU,VBAMacros
canonical_url: https://geekexcel.com/how-to-dynamically-hide-or-unhide-multiple-tabs-using-vba-in-excel/
---

In this article, we will talk about how to **dynamically hide or unhide multiple tabs** using VBA in Excel by using Example. Let’s see them below!! Get an official version of ** MS Excel**  from the following link: [https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)

## Jump To:

- [Example](#h-example)
- [A Short Closure](#2)

## Example

- Firstly, you need to  **create hide or unhide multiple tabs** in Excel.

![](https://geekexcel.com/wp-content/uploads/2021/09/Sample-data-33.png)<figcaption>Sample data</figcaption>

- In the Excel Worksheet, you have to go to the  **Developer Tab.**
- Then, you need to ** ** select the  **Visual Basic**  option under the  **Code**  section.

![Select Visual Basic](https://geekexcel.com/wp-content/uploads/2021/09/Select-Visual-Basic-9-1024x180.png)<figcaption>Select Visual Basic</figcaption>

- Now, you have to click on **Insert** and then select **Module**.

![Insert a module](https://geekexcel.com/wp-content/uploads/2021/09/Insert-a-module.png)<figcaption>Insert a module</figcaption>

- Now, you have to  **copy and paste the code**  given below.

Hide Tab Code:

```
Sub HideTabs()Dim TabNo As DoubleDim LastTab As Double
LastTab = Range("Hide_TabsDNR").Count
On Error Resume Next
For TabNo = 2 To LastTab
Sheets(Range("Hide_TabsDNR")(TabNo)).Visible = False
Next TabNo
On Error GoTo 0
Sheets(1).Select
End Sub

```

UnHide Tab Code:

```
Sub UnHideTabs()
    Dim TabNo As Double
    Dim LastTab As Double
    LastTab = Range("Hide_TabsDNR").Count
    On Error Resume Next
    For TabNo = 2 To LastTab
        Sheets(Range("UnHide_TabsDNR")(TabNo)).Visible = True
    Next TabNo
    On Error GoTo 0
    Sheets(1).Select
End Sub

```

- You need to  **save the code**  by selecting it and then  **close the window**.

![](https://geekexcel.com/wp-content/uploads/2021/09/Save-the-Code-70.png)<figcaption>Save the Code</figcaption>

- Again, you have to go to the  **Excel Spreadsheet** , and click on the  **Developer Tab**.
- You need to choose the  **Macros option**  in the Code section.

![Choose Macro option](https://geekexcel.com/wp-content/uploads/2021/09/Choose-Macro-option-11-1024x184.png)<figcaption>Choose Macro option</figcaption>

- Then, you have to make sure that your  **macro name is selected**  and click the  **Run ** button.

![](https://geekexcel.com/wp-content/uploads/2021/09/Run-the-Code-41.png)<figcaption>Run the Code</figcaption>

- Now, if you click on **Hide button,** then all the **listed sheets** will be **hidden**.

![](https://geekexcel.com/wp-content/uploads/2021/09/Hide-Button.png)<figcaption>Click on the Hide button</figcaption>

- Finally, if you click on **Unhide button** , then all the **hidden sheets** that are mentioned in column D will get **unhide**.

![](https://geekexcel.com/wp-content/uploads/2021/09/UnHide-Button.png)<figcaption>Click on UnHide Button</figcaption>

## A Short Closure

We hope that this short tutorial gives you guidelines ** ** on how to **dynamically hide or unhide multiple tabs** using VBA in Excel. Please leave a comment in case of any  **queries,**  and don’t forget to mention your valuable  **suggestions**  as well. Thank you so much for Visiting Our Site!! Continue learning on **[Geek Excel](https://geekexcel.com/)!! **Read more on [**Excel Formulas**](https://geekexcel.com/excel-formula/) **!!**

**Keep Reading:**

- **[How to Fill Cell References From Multiple Worksheets in Excel?](https://geekexcel.com/how-to-fill-cell-references-from-multiple-worksheets-in-excel/)**
- **[How to Search for a Value in All Tabs in Excel Office 365?](https://geekexcel.com/how-to-search-for-a-value-in-all-tabs-in-excel-office-365/)**
- **[Use COMMAND RIBBON Options in Microsoft Excel 365!](https://geekexcel.com/use-command-ribbon-options-in-microsoft-excel-365/)**
- **[How to Sort Sheets/Worksheets Alphabetically in Excel Office 365?](https://geekexcel.com/how-to-sort-sheets-worksheets-alphabetically-in-excel-office-365/)**
- **[How to Unhide a Worksheet in Microsoft Excel 365?](https://geekexcel.com/how-to-unhide-a-worksheet-in-microsoft-excel-365/)**