|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 按钮1_Click()
Set d = CreateObject("scripting.dictionary")
arr = [a1].CurrentRegion
r = 0
For j = 1 To UBound(arr)
str1 = arr(j, 1) & "##" & arr(j, 2)
If Not d.exists(str1) Then
d(str1) = ""
r = r + 1
arr(r, 1) = arr(j, 1)
arr(r, 2) = arr(j, 2)
End If
Next j
d.RemoveAll
rx = 0
For j = 1 To r
If Not d.exists(arr(j, 2)) Then
rx = rx + 1
d(arr(j, 2)) = rx
arr(rx, 1) = arr(j, 1)
arr(rx, 2) = arr(j, 2)
Else
arr(d(arr(j, 2)), 1) = arr(d(arr(j, 2)), 1) & "\" & Mid(arr(j, 1), 4)
End If
Next j
[g1].Resize(rx, 2) = arr
End Sub
|
|