|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
'你也没说,去重就可以了
Option Explicit
Sub test()
Dim arr, i, j, k, m, n, t
arr = Sheets("sheet1").[a1].CurrentRegion
ReDim brr(1 To UBound(arr, 1), 1 To 3)
n = n + 1
brr(1, 1) = arr(2, 6): brr(1, 2) = arr(2, 10): brr(1, 3) = arr(2, 11)
For i = 3 To UBound(arr, 1)
If arr(i, 10) <> arr(i - 1, 10) Then
If InStr(brr(n, 1), "/") Then
t = Split(brr(n, 1), "/"): m = 0
For j = 0 To UBound(t)
t(m) = t(j)
For k = 0 To m - 1
If t(k) = t(m) Then Exit For
Next
If k = m Then m = m + 1
Next
ReDim Preserve t(m - 1)
If UBound(t) > 0 Then
brr(n, 1) = Join(t, "/")
Else
brr(n, 1) = t(0)
End If
End If
n = n + 1
brr(n, 1) = arr(i, 6): brr(n, 2) = arr(i, 10): brr(n, 3) = arr(i, 11)
Else
brr(n, 1) = brr(n, 1) & "/" & arr(i, 6)
End If
Next
With Sheets("sheet2").[d2]
.Resize(Rows.Count - 1, UBound(brr, 2)).ClearContents
.Resize(n, UBound(brr, 2)) = brr
End With
End Sub |
评分
-
1
查看全部评分
-
|