How to Count the Number of Visible Sheets in a Workbook?


It can be difficult to keep track of how many sheets are showing at once if you've ever worked with large Excel files including a lot of sheets. Excel offers a variety of tools and capabilities to make managing and working with data easier, and counting visible sheets is no exception.

We'll walk you through each step of counting the visible sheets in an Excel spreadsheet in this tutorial. This video will provide you the knowledge and abilities necessary to swiftly ascertain the number of visible sheets in your workbook, regardless of your level of Excel proficiency. So, let's dive in and learn how to count the number of visible sheets in Excel, allowing you to organize and navigate your workbooks with ease!

Count The Number Of Visible Sheets In A Workbook

Here, we will first create a VBA module and then run it to complete the task. So let us see a simple process to learn how you can count the number of visible sheets in a workbook in Excel.

Step 1

Consider any Excel workbook that has hidden worksheets.

First, right-click on the sheet name and select View Code to open the VAB application.

Right click > View code.

Step 2

Then click on Insert and select Module, then copy the below code into the textbox.

Insert > Module > Copy.

Code

Sub VisibleSheetsCount()
   Dim xSht As Variant
   Dim I As Long
   For Each xSht In ActiveWorkbook.Sheets
      If xSht.Visible Then I = I + 1
   Next
   MsgBox I & " sheets are visible", , "Count Visible Sheets"
End Sub

Step 3

Finally, save the sheet as a macro-enabled template and click F5 to display the number of sheets.

Save > F5.

This is how you can count the number of visible sheets in a workbook.

Conclusion

In this tutorial, we have used a simple example to demonstrate how you can count the number of visible sheets in a workbook in Excel to highlight a particular set of data.

Updated on: 22-Aug-2023

113 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements