
如何在Excel中計算具有特定名稱的工作表?
您是否曾經嘗試過計算以名字開頭或包含特定單詞的工作表的數量? 例如,計算名稱以“ KTE”開頭或包含“ KTE”的工作表的數量。 本文將提供幫助您顯示問題的方法。
使用VBA代碼對具有特定名稱的工作表進行計數
快速查找工作表名稱中包含特定單詞的所有工作表使用VBA代碼對具有特定名稱的工作表進行計數以下VBA代碼可幫助您計算工作簿中具有特定名稱的工作表的數量。 請執行以下操作。
驚人的! 在 Excel 中使用高效的選項卡,如 Chrome、Firefox 和 Safari!每天節省50%的時間,并減少數千次鼠標單擊!1。 按 其他 + F11 鍵打開 Microsoft Visual Basic應用程序 窗口。
2.在 Microsoft Visual Basic應用程序 窗口中,單擊 插頁 > 模塊,然后將以下VBA代碼復制到“代碼”窗口中。
VBA代碼1:計算名稱以“ KTE”開頭的工作表
Sub CountWSNames()Dim I As LongDim xCount As IntegerFor I = 1 To ActiveWorkbook.Sheets.CountIf Mid(Sheets(I).Name, 1, 3) = "KTE" Then xCount = xCount + 1NextMsgBox "There are " & CStr(xCount) & " sheets that start with KTE", vbOKOnly, "KuTools for Excel"End SubCopyIf 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 LongDim xCount As IntegerFor I = 1 To ActiveWorkbook.Sheets.CountIf InStr(1, Sheets(I).Name, "KTE") > 0 Then xCount = xCount + 1NextMsgBox "There are " & CStr(xCount) & " sheets that with KTE", vbOKOnly, "KuTools for Excel"End SubNote: 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”: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.Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.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. Then all worksheets whose name contain the specific word are filtered and listed in the worksheet list box. See screenshot:If you want to have a free trial (30-day) of this utility, please click to download it, and then go to apply the operation according above steps.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 ToolsTransform Hours into Minutes with Kutools for Excel!Ready to supercharge your Excel tasks? Harness the power of Kutools for Excel - your ultimate time-saving tool. Streamline intricate tasks and glide through your data like a pro. Experience Excel at lightning speed!Why You Need Kutools for Excel
