Option Explicit
Sub test()
Dim arr, i, j, k, kk, n, flag As Boolean
arr = Range("a2:j" & Cells(Rows.Count, "a").End(xlUp).Row + 1)
ReDim brr(1 To UBound(arr, 1) - 1, 1 To UBound(arr, 2))
For i = 1 To UBound(arr, 1) - 1
flag = True
For j = i To UBound(arr, 1) - 1
If flag Then
For k = 5 To 8
If arr(j, k) = 1 Then flag = False: Exit For
Next
End If
If arr(j, 1) <> arr(j + 1, 1) Then
If flag Then
n = n + 1
brr(n, 1) = arr(i, 1): brr(n, 9) = "满勤": brr(n, 10) = arr(i, 10)
Else
For k = i To j
n = n + 1
For kk = 1 To UBound(arr, 2): brr(n, kk) = arr(k, kk): Next
Next
End If
i = j: Exit For
End If
Next j, i
[l2].Resize(UBound(brr, 1), UBound(brr, 2)) = brr '输出位置自己修改一下
End Sub |