How to count worksheets with specific name in Excel?
Have you ever tried to count number of worksheets whose name start with or contain specific word? For example, count the number of worksheets that name start with or contain “KTE”. This article will provide method to help you show the problem.
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
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: Please replace the word “KTE” with the one you need count number of worksheets based on.
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”:
This section will show you how to quickly find all worksheets with specific name in current workbook with Kutools for Excel.
1. After installing Kutools for Excel, the Kutools’ Navigation pane will be opened automatically on the left side of workbook. Otherwise, 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. Then all worksheets whose name contain the specific word are filtered and listed in the worksheet list box. See screenshot:
- 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?