|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub ruby2()
- '须安装ACTIVERUBY.才能运行
- '下载地址 http://www.artonx.org/data/asr/ActiveRuby.msi
- Set x = CreateObject("scriptcontrol")
- x.Language = "rubyscript"
- Row = [a4].End(xlDown).Row
- Range("A4:K" & Row).Interior.ColorIndex = 2
- [l2:l888] = Empty
- y = x.eval("def aa aa,bb,cc ;$aa=aa;$kk=bb;$ll=cc;end;")
- y = x.Run("aa", Sheet1.UsedRange.Value, [j2].Value, [j3].Value)
- y = x.eval("zz=[];yy=[];kk='';arr='';brr=$aa.map{|x|x[10]};bb=$aa[6..-1].reverse.map{|x|x[10]};catch (:aaa) do;(2..bb.size-1).each{|x|bb.combination(x).to_a.each{|y|mm=y.inject(&:+);zz=y and throw(:aaa) if mm==$kk };};end;arr;zz.each{|x|yy<<brr.index(x)+1};yy")
- For Each yy In y
- Range("A" & yy & ":K" & yy).Interior.ColorIndex = 4
- Cells(yy, 12) = [j2].Value
- Next
- y = x.eval("zz=[];yy=[];kk='';arr='';brr=$aa.map{|x|x[10]};bb=$aa[6..-1].reverse.map{|x|x[10]};catch (:aaa) do;(2..bb.size-1).each{|x|bb.combination(x).to_a.each{|y|mm=y.inject(&:+);zz=y and throw(:aaa) if mm==$ll };};end;arr;zz.each{|x|yy<<brr.index(x)+1};yy")
- For Each yy In y
- Range("A" & yy & ":K" & yy).Interior.ColorIndex = 8
- Cells(yy, 12) = [j3].Value
- Next
- End Sub
复制代码
[ 本帖最后由 figfig 于 2011-5-11 17:18 编辑 ] |
|