|
Dim dic As Object, wb As Workbook, filename
Dim arr, brr()
Set dic = CreateObject("Scripting.Dictionary")
filename = Dir(ThisWorkbook.Path & "\" & "*.xlsx")
Do
If filename = "" Then
Exit Do
Else
'读取文件名
Worksheets("跟班登记表").Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = filename
'获取数据
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & filename)
arr = wb.Sheets(1).Range("b4:f27")
wb.Close True
Set wb = Nothing
'数据分析
k = 0
ReDim brr(1 To 29, 0 To 20)
dic.RemoveAll
For j = 1 To 5
For i = 1 To 24
If arr(i, j) <> "" Then
If Not dic.exists(arr(i, j)) Then
k = k + 1
brr(k, 0) = arr(i, j)
dic(arr(i, j)) = k
End If
If brr(dic(arr(i, j)), (j - 1) * 4 + 1) = 0 Then
brr(dic(arr(i, j)), (j - 1) * 4 + 1) = 1
ElseIf brr(dic(arr(i, j)), (j - 1) * 4 + 2) = 0 Then
brr(dic(arr(i, j)), (j - 1) * 4 + 2) = 1
ElseIf brr(dic(arr(i, j)), (j - 1) * 4 + 3) = 0 Then
brr(dic(arr(i, j)), (j - 1) * 4 + 3) = 1
ElseIf brr(dic(arr(i, j)), (j - 1) * 4 + 4) = 0 Then
brr(dic(arr(i, j)), (j - 1) * 4 + 4) = 1
End If
End If
Next
Next
ActiveSheet.[b4].Resize(29, 21) = brr
End If
filename = Dir
Loop
End Sub
考勤登记.zip
(98.26 KB, 下载次数: 2)
|
|