'自定义函数Vlookup1 0 表名,1查找列,2查找值,3返回值列
dim dr as datarow = datatables(args(0)).find(args(1) & "= '" & args(2) & "'")
if dr isnot nothing then
return dr(args(3))
else
return nothing
end if
'自定义函数Vlookup2 0 表名,1查找列,2查找值,3返回值列
dim r as integer = tables(args(0)).find(args(2),0,args(1),false,true,false)
if r> -1 then
return tables(args(0)).rows(r)(args(3))
else
return nothing
end if
'测试效率
Dim st As Date = Date.Now
functions.execute("vlookup1",表名,查找列,查找值,返回值列)
MessageBox.Show("vlookup1耗时: " & (Date.Now - st).TotalSeconds & "秒")
st = now
functions.execute("vlookup2",表名,查找列,查找值,返回值列)
MessageBox.Show("vlookup2耗时: " & (Date.Now - st).TotalSeconds & "秒")