|
- Sub main()
- Dim s1$, s$, js As Object, j$, arr, r&, i&, brr()
- r = Range("a:b").Find("*", , , , 1, 2).Row: arr = Range("a1:b" & r)
- For i = 1 To UBound(arr): s1 = s1 & "," & arr(i, 1): s = s & "," & "'" & arr(i, 2) & "'": Next
- Set js = CreateObject("MSScriptControl.ScriptControl")
- js.Language = "JavaScript"
- j = "o={};'" & s1 & "'.replace(/[^,]+/g,function(s){o[s]=0});"
- j = j & "function fu(o,a){b=[];for(k in o)for(i=0;i<a.length;i++)if(a[i].indexOf(k)!=-1)b.push(a[i].split(k)[1]);return b};"
- j = j & "b=fu(o," & "[" & Mid(s, 2) & "]" & ");": r = js.eval(j & "b.length")
- ReDim brr(1 To r, 1 To 1)
- For i = 0 To r - 1: brr(i + 1, 1) = js.eval("b[" & i & "]"): Next
- Range("c1").Resize(r) = brr
- End Sub
复制代码
|
|