- Dim arr, brr, d As Object, i&, j&, x, x1, x2
- Set d = CreateObject("scripting.dictionary")
- arr = Sheets(1).Range("a1").CurrentRegion
- For i = 2 To UBound(arr)
- x = Split(arr(i, 2), " ")
- If Not d.exists(arr(i, 1) & "," & x(0)) Then d.Add arr(i, 1) & "," & x(0), x(1) Else d(arr(i, 1) & "," & x(0)) = d(arr(i, 1) & "," & x(0)) & "," & x(1)
- Next
- ReDim brr(1 To d.Count, 1 To 10)
- a = d.keys: b = d.items
- For i = 0 To d.Count - 1
- x1 = Split(a(i), ",")
- brr(i + 1, 1) = x1(0)
- brr(i + 1, 2) = x1(1)
- x2 = Split(b(i), ",")
- For j = 0 To UBound(x2)
- brr(i + 1, j + 3) = x2(j)
- Next
- Next
- Sheets(2).Activate
- Cells.ClearContents
- Range("a1:h1") = Array("姓名", "日期", "考勤1", "考勤2", "考勤3", "考勤4", "考勤5", "考勤6")
- Range("a2").Resize(UBound(brr), UBound(brr, 2)) = brr
复制代码 修改这一句就行了:ReDim brr(1 To d.Count, 1 To 10)
|