|
Sub AwTest()
Dim i&, j%, k%, r&, xh%, qh%, arr, brr, d As Object
Set d = CreateObject("Scripting.Dictionary")
arr = Range("N3:AL" & Cells(Rows.Count, "N").End(3).Row)
For i = 3 To UBound(arr)
For j = 2 To UBound(arr, 2) Step 3
If arr(i, j + 2) = "满柜" Then d(i - 2 & "|" & j) = ""
Next
Next
ReDim crr(1 To d.Count, 1 To 7)
If Cells(Rows.Count, 1).End(3).Row > 4 Then
brr = Range("A5:G" & Cells(Rows.Count, 1).End(3).Row)
For i = 1 To UBound(brr)
k = Val(Split(brr(i, 3), "第")(1))
If d.Exists(brr(i, 4) & "|" & k * 3 - 1) Then
r = r + 1: crr(r, 1) = r
For j = 2 To UBound(brr, 2)
crr(r, j) = brr(i, j)
Next
d.Remove brr(i, 4) & "|" & k * 3 - 1
End If
Next
End If
If d.Count Then
For i = 1 To d.Count
r = r + 1: crr(r, 1) = r: crr(r, 2) = Date
xh = Split(d.Keys()(i - 1), "|")(0)
qh = Split(d.Keys()(i - 1), "|")(1)
For k = 0 To 2
crr(r, 5 + k) = arr(xh + 2, qh + k)
Next
crr(r, 3) = "第" & (qh + 1) / 3 & "区"
crr(r, 4) = xh
Next
End If
If r Then
[A5:G500] = ""
[A5].Resize(r, UBound(crr, 2)) = crr
End If
End Sub |
|