|
- Sub test()
- Range("A4:F100").ClearContents
- ar = Sheets("数据源").Range("A1").End(4).Row
- arr = Sheets("数据源").Range("A2:R" & ar)
- Dim brr(1 To 100, 1 To 6)
- myr = Array(12, 9, 16, 18, 4)
- For i = 1 To ar - 1
- If Int(arr(i, 12)) = [B3] Then
- m = m + 1
- brr(m, 1) = m
- For j = 2 To 6
- brr(m, j) = arr(i, myr(j - 2))
- Next
- End If
- Next
- If m = 0 Then
- MsgBox "未找到该日期对应的数据!"
- Exit Sub
- End If
- Set d = CreateObject("Scripting.Dictionary")
- For k = 1 To m
- d(brr(k, 2) & "-" & brr(k, 3) & "-" & brr(k, 4) & "-" & brr(k, 5)) = d(brr(k, 2) & "-" & brr(k, 3) & "-" & brr(k, 4) & "-" & brr(k, 5)) + Val(brr(k, 6))
- Next
- k = d.keys
- t = d.items
- [A4].Resize(1, 6) = Array("No", "收货日期", "产品型号", "拉别", "工程师", "数量")
- For l = 1 To d.Count
- Cells(l + 4, 1) = l
- Next
- [B5].Resize(d.Count, 1) = Application.Transpose(k)
- [B5].Resize(d.Count, 1).TextToColumns other:=True, otherchar:="-"
- [F5].Resize(d.Count, 1) = Application.Transpose(t)
- Set d = Nothing
- End Sub
复制代码 |
|