sub test()
dim dic as object,mAry,mRow as long,
set dic=createobject("scripting.dictionary")
with workSheets("数据")
mrow=.cells(.rows.count,1).end(3).row
mAry=.[a2].resize(mrow-1,2)
end with
for i=1 to ubound(mary,1)
dic("" & mary(i,1))=mary(i,2)
next i
with worksheets("求解表")
mrow=.cells(.rows.count,1).end(3).row
mAry=.[a2].resize(mrow-1,1)
for i=1 to ubound(mary,1)
if dic.exists("" & mary(i,1)) then
mary(i,1)=dic.exists("" & mary(i,1))
else
mary(i,1)="NO find!"
end if
next i
.[b2].resize(ubound(mary,1),1)=mary
end with
end sub
追问谢谢啊,显示dim dic as object,mAry,mRow as long,这个是语法错误,如果删除这个一行就得出的结果是NO Find 和 Ture。
追答呃,手写的代码。。
修改如下
sub test()
dim dic as object,mAry,mRow as long
set dic=createobject("scripting.dictionary")
with workSheets("数据")
mrow=.cells(.rows.count,1).end(3).row
mAry=.[a2].resize(mrow-1,2)
end with
for i=1 to ubound(mary,1)
dic("" & mary(i,1))=mary(i,2)
next i
with worksheets("求解表")
mrow=.cells(.rows.count,1).end(3).row
mAry=.[a2].resize(mrow-1,1)
for i=1 to ubound(mary,1)
if dic.exists("" & mary(i,1)) then
mary(i,1)=dic("" & mary(i,1))
else
mary(i,1)="NO find!"
end if
next i
.[b2].resize(ubound(mary,1),1)=mary
end with
end sub