|
我给你改一个64位office版本的 也能用的代码,请测试!- Sub main()
- Dim arr, j$, r&, i&, s$
- r = Cells(Rows.Count, 1).End(3).Row: arr = Range("a1:c" & r)
- For i = 2 To r: s = s & "," & arr(i, 1): Next
- j = "o={},i=0,r=/''/;'" & s & "'.replace(/[^,]+/g,function(s){o[s]=i++;});for(k in o)r+='|'+k;"
- j = j & "function f(k){return o.hasOwnProperty(k)?o[k]:i;};"
- j = j & "function q(x,y){return f((m=x[0].match(r))?m[0]:'')-f((n=y[0].match(r))?n[0]:'');};"
- Call mySort(arr, j, 2, 2, r, 3)
- Range("e1").Resize(r, 3) = arr
- MsgBox "ok!"
- End Sub
- Sub mySort(ByRef a, ByVal p$, ByVal l1&, ByVal l2&, ByVal u1&, ByVal u2&)
- Dim js As Object, D As Object, i&, j&, s$, sr$
- Set D = CreateObject("htmlfile"): Set js = D.parentWindow
- For i = l1 To u1
- For j = l2 To u2
- s = s & "," & "'" & a(i, j) & "'"
- Next
- sr = sr & "," & "[" & Mid(s, 2) & "]": s = Empty
- Next
- js.execScript "a=" & "[" & Mid(sr, 2) & "]" & ";" & p & "a.sort(q);"
- For i = l1 To u1
- For j = l2 To u2
- a(i, j) = js.eval("a[" & i - l1 & "][" & j - l2 & "]")
- Next
- Next
- End Sub
复制代码
|
|