|
本帖最后由 duquancai 于 2018-9-1 22:07 编辑
再挤牙膏 就没有意思了!!!请测试如下代码!- Sub main()
- Dim arr, k$, s$, j$, brr(), l&, d As Object, js As Object
- arr = Range("h1:h" & Cells(Rows.Count, "h").End(3).Row)
- k = [j1]: Range("k:k").Clear: Range("k:k").NumberFormat = "@"
- For i = 1 To UBound(arr)
- If Len(arr(i, 1)) Then s = s & "," & "'" & arr(i, 1) & "'"
- Next
- s = "[" & Mid(s, 2) & "]"
- Set d = CreateObject("htmlfile"): Set js = d.parentWindow
- js.execScript "k='" & k & "'.split(''),b=[],a=" & s & ",o={};"
- j = "for(j=0;j<k.length;j++){for(i=0;i<a.length;i++){s=''+(a[i].slice(-2,-1)*1+a[i].slice(-3,-2)*1);"
- j = j & "if(s.charAt(s.length-1)===k[j])o[a[i]]=0;};};for(k in o)b.push(k);b.sort(function(x,y){return x*1-y*1});"
- l = js.eval(j & "b.length"): ReDim brr(1 To l, 1 To 1)
- For i = 0 To l - 1
- brr(i + 1, 1) = js.eval("b[" & i & "];")
- Next
- Range("k1").Resize(l, 1) = brr
- End Sub
复制代码 |
|