我正在尝试制作一个可以遍历整个工作簿并计算员工工作天数的宏。工作表以天为单位完成工作,因此 T 必须找到的天数不为零。我试过使用COUNTIF(A11:A12,">0")
,我得到了错误Expected : list separator or )
。我正在使用For Each
循环来处理工作表。我想将所有信息放在工作簿末尾的新工作表上,其中包含员工姓名和工作天数。我对 Visual Basic 很陌生,但对 C# 非常熟悉。
我现在已经走到了这一步
Option Explicit
Sub WorksheetLoop2()
' Declare Current as a worksheet object variable.
Dim Current As Worksheet
Dim LastColumn As Integer
If WorksheetFunction.CountA(Cells) > 0 Then
' Search for any entry, by searching backwards by Columns.
LastColumn = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
End If
' Loop through all of the worksheets in the active workbook.
For Each Current In Worksheets
Current.Range("A27") = Application.WorksheetFunction.CountIf(Current.Range(Cells(11, LastColumn), Cells(16, LastColumn)), ">0")
Current.Range("A28") = Application.WorksheetFunction.CountIf(Current.Range("Al17:Al22"), ">0")
Next
End Sub
当我运行它时,我收到一条错误消息method range of object'_worksheet' failed
。我也无法找到一种方法来获取摘要表上的所有信息。