|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub test() arr = Sheet1.Range("a1").CurrentRegion ReDim brr(1 To 1000, 1 To 5) k = 1 For i = 4 To UBound(arr, 2) m = Sheet1.Application.Max(Columns(i)) For j = 2 To UBound(arr) If arr(j, i) = m Then brr(k, 1) = arr(j, 1) brr(k, 2) = arr(j, 2) brr(k, 3) = arr(j, 3) brr(k, 4) = arr(1, i) brr(k, 5) = arr(j, i) k = k + 1 End If Next Next For i = 1 To UBound(brr) With Sheet2 If Not IsEmpty(brr(i, 1)) Then .Cells(i + 1, 1) = brr(i, 1) .Cells(i + 1, 2) = brr(i, 2) .Cells(i + 1, 3) = brr(i, 3) .Cells(i + 1, 4) = brr(i, 4) .Cells(i + 1, 5) = brr(i, 5) End If End With Next End Sub |
|