For Each r1 As Row In Tables("TEST表").Rows
W1 = r1("测试1")
W2 = r1("测试2")
Dim dr1 As DataRow
dr1 = DataTables("物料表").Find("物料编码 = '"& W1 & "'")
if dr1 isnot nothing then
r1("数量1") = dr1("成品")
end if
Dim dr2 As DataRow
dr2 = DataTables("物料表").Find("物料编码 = '"& W2 & "'")
if dr2 isnot nothing then
r1("数量2") = dr2("外协1")
r1("数量3") = dr2("外协2")
end if
Next