excel vba项目需要此文件。基本上,我已经使用宏创建了许多工作表,并且在执行结束时,宏应该告诉创建了多少个工作表。
答案 0 :(得分:0)
类似...
Option Explicit
Public Sub CountAddedSheets()
Dim vInitialCount As Long
Dim vWorkbook As Workbook
Set vWorkbook = ActiveWorkbook
' Remember the initial number of sheets
vInitialCount = ActiveWorkbook.Worksheets.Count
' Your code to add worksheets ... for example ...
vWorkbook.Worksheets.Add
' Show the number of worksheets added
MsgBox "Number of worksheets added: " & (vWorkbook.Worksheets.Count - vInitialCount)
End Sub