|
发表于 2016-6-23 14:27
|
显示全部楼层
本楼为最佳答案
- Sub tt()
- arr = [a1].CurrentRegion
- ReDim brr(2 To UBound(arr), 1 To UBound(arr))
- For i = 2 To UBound(arr)
- brr(i, 1) = arr(i, 1)
- If arr(i, 3) = "N" Then
- brr(i, 2) = "无"
- Else
- n = 1
- ai = Left(arr(i, 2), Len(arr(i, 2)) - 1)
- bi = Val(Right(arr(i, 2), 1))
- For j = 2 To UBound(arr)
- aj = Left(arr(j, 2), Len(arr(j, 2)) - 1)
- bj = Val(Right(arr(j, 2), 1))
- If ai = aj And bi < bj Then
- n = n + 1
- If nmax < n Then nmax = n
- brr(i, n) = arr(j, 1)
- End If
- Next
- If n = 1 Then brr(i, 2) = "无"
- End If
- Next
- [f2].Resize(i - 2, nmax) = brr
- End Sub
复制代码 |
|