|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Function sortarr(arr)
- Dim s As String
- Static sp1 As Object
- If sp1 Is Nothing Then
- s = s & "function Sortarr(arr)" & vbCrLf
- s = s & "{" & vbCrLf
- s = s & "var a, b ;" & vbCrLf
- s = s & "a = arr.toArray();" & vbCrLf
- s = s & "b = a.sort();" & vbCrLf
- s = s & "return(b);" & vbCrLf
- s = s & "}"
- Set sp1 = CreateObject("ScriptControl")
- sp1.Language = "JScript"
- sp1.AddCode s
- End If
- sortarr = Split(sp1.Run("Sortarr", arr), ",")
- End Function
- Sub Mytest()
- 'aa = [a1:a60000] ' 60000个约0.5秒
- aa = Array("张", "王", "李", "赵", "钱", "孙", "周", "吴", "郑", "王")
- t = Timer
- aa = sortarr(aa)
- Debug.Print Timer - t
- '排序结果 吴,周,孙,张,李,王,王,赵,郑,钱
- '说明 排序结果与EXCEL的不同,这个方法的是按照ASC码排序的
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|