|
楼主 |
发表于 2014-1-6 16:21
|
显示全部楼层
《按拼音排序(多列)》
http://club.excelhome.net/thread-838941-1-1.html
VBA.助记字母
蓝桥玄霜
Sub yy()
Dim Arr, i&, n&, r1, c%, j&, aa, Myr&
Dim d, k, t
Set d = CreateObject("Scripting.Dictionary")
Application.ScreenUpdating = False
Sheet3.Activate
Myr = [b65536].End(xlUp).Row
Range("B1:L" & Myr).Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range _
("D2"), Order2:=xlAscending, Key3:=Range("F2"), Order3:=xlAscending, _
Header:=xlYes
Sheet4.Activate
[a3:j1000].ClearContents
Arr = Sheet3.[b1].CurrentRegion
For i = 2 To UBound(Arr)
If Arr(i, 5) = "使用" Then
d(Arr(i, 1)) = d(Arr(i, 1)) & Arr(i, 2) & "," & Arr(i, 3) & "|"
End If
Next
k = d.keys
t = d.items
For i = 0 To UBound(k)
n = 2
Set r1 = Rows(1).Find(k(i))
If Not r1 Is Nothing Then
c = r1.Column
t(i) = Left(t(i), Len(t(i)) - 1)
If InStr(t(i), ",") Then
aa = Split(t(i), "|")
For j = 0 To UBound(aa)
n = n + 1
Cells(n, c) = aa(j)
Next
Else
Cells(n, c) = t(i)
End If
Application.DisplayAlerts = False
Cells(3, c).Resize(n - 2).TextToColumns Comma:=True
Application.DisplayAlerts = True
End If
Next
Application.ScreenUpdating = True
End Sub
|
|