|
- Sub js()
- Dim js As Object, ar, t1, t2
- ar = Range("h1:h" & Cells(Rows.Count, 8).End(3).Row)
- indexs = Space(8) & "假设数据格式ABCD,默认BC组合【2】"
- indexs = indexs & vbCrLf & "1....获取AD组合"
- indexs = indexs & vbCrLf & "2....获取BC组合"
- s = InputBox(indexs, " 获取组合方式", 2)
- If s = "" Then End
- If s = 1 Then
- t1 = 0: t2 = 3
- Else
- t1 = 1: t2 = 2
- End If
- Set js = CreateObject("MSScriptControl.ScriptControl"): js.Language = "JavaScript"
- js.AddCode "function aa(a){return new VBArray(a).toArray().sort(function(x,y){return x-y});}"
- js.AddObject "g", js.CodeObject.aa(ar): js.AddCode "k='" & [j1].Text & "'"
- js.AddCode "var js=0;var su='';for(i=0;i<g.length;i++){if(g[i]){var z=g[i].split('');var s=Number(z[" & t1 & "]) +Number(z[" & t2 & "]);if( s>9){s=s-10;};if (k.indexOf(String(s))>=0){js++;su+=g[i]+',';} }};"
- If js.eval("js") > 0 Then [k1].Resize(js.eval("js"), 1) = Application.Transpose(Split(js.eval("su"), ","))
-
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|