How to count worksheets with specific name in Excel?
Have you ever tried to count the number of worksheets in an Excel workbook based on specific naming criteria? For example, worksheets whose names start with or contain a certain word like "KTE." This guide demonstrates how to use VBA code and the powerful features of Kutools for Excel to easily count and filter worksheets that meet your requirements.
Count worksheets with specific name with VBA code
Quickly find all worksheets that contain specific word in sheet name
Count worksheets with specific name with VBA code
The following VBA codes help you to count number of worksheets with specific name in a workbook. Please do as follows.
1. Press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, click Insert > Module, then copy below VBA code into the Code window.
VBA code 1: Count worksheets whose name start with “KTE”
Sub CountWSNames()
Dim I As Long
Dim xCount As Integer
For I = 1 To ActiveWorkbook.Sheets.Count
If Mid(Sheets(I).Name, 1, 3) = "KTE" Then xCount = xCount + 1
Next
MsgBox "There are " & CStr(xCount) & " sheets that start with 'KTE'", vbOKOnly, "KuTools for Excel"
End Sub
If you want to count number of worksheets contain “KTE”, please apply below VBA code 2.
VBA code 2: Count worksheets whose name contain “KTE”
Sub CountWSNames()
Dim I As Long
Dim xCount As Integer
For I = 1 To ActiveWorkbook.Sheets.Count
If InStr(1, Sheets(I).Name, "KTE") > 0 Then xCount = xCount + 1
Next
MsgBox "There are " & CStr(xCount) & " sheets that with 'KTE'", vbOKOnly, "KuTools for Excel"
End Sub
Note: Replace the word “KTE” with the text you want to use to count the number of worksheets.
3. Press the F5 key to run the code. Then a dialog box will pop up to tell you how many worksheets in current workbook start with “KTE” or contain “KTE”. See screenshots:
Number of worksheets whose name start with “KTE”:
Number of worksheets whose name contain “KTE”:
Quickly find all worksheets that contain specific word in sheet name
This section will show you how to quickly find all worksheets that contain specific word in sheet name with Kutools for Excel.
1. After installing Kutools for Excel, the Kutools’ Navigation pane will be opened automatically on the left side of workbook. Or you can enable the pane by clicking Kutools > Navigation as below screenshot shown.
2. In the Workbook & Sheet section of the navigation pane, check the Filter box and enter the specific worksheet name you with find worksheets based on. All worksheets whose names contain the specific word will be filtered and listed in the worksheet list box. See screenshot:
Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now
Related articles:
- How to reference tab name in cell in Excel?
- How to match the cell value with sheet tab name or vice versa in Excel?
- How to open a specific worksheet by the selected value of a Combo Box in Excel?
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
All Kutools add-ins. One installer
Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.





- All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
- One installer, one license — set up in minutes (MSI-ready)
- Works better together — streamlined productivity across Office apps
- 30-day full-featured trial — no registration, no credit card
- Best value — save vs buying individual add-in