|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub t()
- '需要安装ACTIVERUBY ,下载地址 http://www.artonx.org/data/asr/Ruby-2.1.1.msi
- Set ojs = CreateObject("scriptcontrol"): ojs.Language = "rubyscript"
- ojs.eval ("def aa(aa,bb);$aa=aa;$bb=bb;end")
- y = ojs.Run("aa", Sheet2.UsedRange.Value, Sheet1.Range("a2", Sheet1.[b2].End(4)).Value)
- y = ojs.eval("h={};$aa[1..-1].each{|x|(h[x[0]]||=[])<<x[1..2]};c=[];$bb.each{|x|b=[];h[x[0]].each{|i|if i[1]<=x[1];b<<[i[0],i[1].to_i].join('/');x[1]=x[1]-i[1];elsif i[1]>x[1];b<<[i[0],x[1].to_i].join('/');break;end};c<<b.join(';')};c.zip")
- Sheet1.[c2].Resize(UBound(y) + 1) = y
- Set ojs = Nothing
- 'Stop
- End Sub
复制代码 |
|