我想计算工作簿中的工作表数量,然后从总计数中减去特定的工作表。我错过了什么?这给了我一个对象错误:
wsCount = ThisWorkbook.Sheets.Count - ThisWorkbook.Sheets("Sheety1").Count -
ThisWorkbook.Sheets("Sheety2").Count
答案 0 :(得分:3)
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