|
本帖最后由 duquancai 于 2018-6-20 22:29 编辑
- Sub main()
- Dim ar, r&, i&
- Set js = CreateObject("MSScriptControl.ScriptControl")
- js.Language = "JavaScript": js.AddObject "rg", Sheets("表二").Range("g3")
- js.AddCode "var r1=/''/,r2=/''/;r1.compile(/\d+[*+](?:1\.5|[23])/g);r2.compile(/[*+]/);"
- r = Sheets("表一").Cells(Sheets("表一").Rows.Count, "G").End(3).Row
- ar = Sheets("表一").[g3].Resize(r - 2)
- Sheets("表二").Range("g3:g" & r & ",i3:i" & r & ",k3:k" & r) = 0
- For i = 1 To r - 2
- js.eval ("a='" & ar(i, 1) & "'.match(r1);for(i=0;i<a.length;i++){b=a[i].split(r2);if(b[1]==1.5)rg(" & i & ",1)=b[0];else if(b[1]==2)rg(" & i & ",3)=b[0];else if(b[1]==3)rg(" & i & ",5)=b[0];};")
- Next
- MsgBox "OK!结果在表二"
- End Sub
复制代码 |
|