|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 按钮1_Click()
Application.ScreenUpdating = False
Dim brr()
Set d = CreateObject("scripting.dictionary")
arr = [a3:a22]
For j = 1 To UBound(arr)
d(Split(arr(j, 1), "-")(1)) = ""
Next j
a = 0
For j = 1 To UBound(arr)
If Not d.exists(Split(arr(j, 1), "-")(0)) Then
a = a + 1
ReDim Preserve brr(1 To 2, 1 To a)
brr(1, a) = Split(arr(j, 1), "-")(0)
End If
Next j
a = 3
For j = 1 To UBound(brr, 2)
l1:
If brr(1, j) <> "A" Then
For i = 1 To UBound(arr)
If Left(arr(i, 1), 1) = brr(1, j) Then
brr(2, j) = brr(2, j) & "," & arr(i, 1)
brr(1, j) = Right(arr(i, 1), 1)
If brr(1, j) <> "A" Then
str1 = Mid(brr(2, j), 2)
str2 = ""
If InStr(str1, ",") > 0 Then
crr = Split(str1, ",")
For k = UBound(crr) To 0 Step -1
str2 = str2 & "," & Right(crr(k), 1) & "-" & Left(crr(k), 1)
Next k
str2 = Mid(str2, 2)
Else
str2 = Right(str1, 1) & "-" & Left(str1, 1)
End If
Cells(a, 5) = str2
Cells(a, 3) = Mid(brr(2, j), 2)
a = a + 1
End If
End If
Next i
GoTo l1
End If
Next j
Application.ScreenUpdating = True
End Sub |
|