|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub test()
Set d = CreateObject("scripting.dictionary")
arr = ActiveSheet.UsedRange.Value
dm = CStr([a1].Value)
'数据段自第三行开始
For i = 3 To UBound(arr)
If arr(i, 1) <> "" Then rq = arr(i, 1)
If CStr(arr(i, 3)) = dm Then
d(rq) = i
End If
Next
ReDim brr(1 To d.Count + 1, 1 To 7)
For j = 1 To UBound(brr, 2)
brr(1, j) = arr(3, j)
Next
brr(1, 1) = "日期"
m = 1
For Each Key In d.keys
m = m + 1
brr(m, 1) = Key
For j = 2 To UBound(brr, 2)
brr(m, j) = arr(Val(d(Key)), j)
Next
Next
[I3].Resize(UBound(brr), UBound(brr, 2)) = brr
End Sub
|
|