VBA计算具有特定名称的工作表的数量(简单)

Sea*_*ly 1 excel vba

我想计算工作簿中的工作表数量,然后从总数中减去特定工作表。我缺少什么?这给了我一个对象错误:

wsCount = ThisWorkbook.Sheets.Count - ThisWorkbook.Sheets("Sheety1").Count -
ThisWorkbook.Sheets("Sheety2").Count  
Run Code Online (Sandbox Code Playgroud)

K.F*_*oul 5

cpt = 0
For Each ws In ActiveWorkbook.Worksheets
    If ws.Name = "Sheety1" Or ws.Name = "Sheety2" Then
        cpt = cpt + 1 
    Else 
        'Do nothing
    End If 
Next
wsCount = ThisWorkbook.Sheets.Count - cpt
Run Code Online (Sandbox Code Playgroud)