|
楼主 |
发表于 2023-7-4 09:35
|
显示全部楼层
- Sub 转置()
- Dim Arr, Brr(), i, j, kk, n, nRow
- Dim DicSs As Object: Set DicSs = CreateObject("scripting.dictionary")
- Arr = [a1].CurrentRegion
- For i = 2 To UBound(Arr)
- If Arr(i, 3) <> "" Then DicSs(Arr(i, 3)) = DicSs(Arr(i, 3)) + 1
- Next
- For Each kk In DicSs.keys
- ReDim Brr(1 To 2, 1 To DicSs(kk) + 1)
- Brr(1, 1) = kk: n = 1
- For i = 2 To UBound(Arr)
- If Arr(i, 3) = kk Then
- n = n + 1
- Brr(1, n) = Arr(i, 1)
- Brr(2, n) = Arr(i, 2)
- End If
- Next
- nRow = [f1048576].End(3).Row + 1
- Cells(nRow, 5).Resize(UBound(Brr), UBound(Brr, 2)) = Brr
- Next
- End Sub
复制代码
于箱长 发表于 2023-7-4 09:17
谢谢老师,好了。 |
|