好的,所以我知道这非常不正确。我收到语法错误。 但我总体上试图找到一种更好的方法来做到这一点。 我想将订单号与另一张表中的订单号相匹配,并将所有数据从那里获取到我当前的表中。
Sub Lookup()
On Error Resume Next
For Each row In Worksheets("batches").Range("B4:B1384")
Result = Application.evaluate("VLOOKUP(row, Worksheets("OrderLvl").Range("C4:DL1384"),{3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116}, FALSE)")
If Result = "Error 2042" Then
'nothing found
End If
Next
On Error GoTo 0
End Sub
答案 0 :(得分:1)
您没有说明您要对数据做什么,但我建议改为使用$query = "SELECT * FROM applicants";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
var_dump($row);
}
:
Match
答案 1 :(得分:0)
如果你想保留vlookup,我建议在这里使用范围类型:
Dim LookUpRange As Range
Dim row As Range
Set LookUpRange = Worksheets("batches").Range("B4:B1384")
Result = Application.evaluate("VLOOKUP(" & row.row() & "," & LookUpRange & "," & I &",FALSE)")
并将其推入一个循环,该循环遍历您需要从中获取数据的列的主机,使用I表示“{3,4,5,6,7,8,9,10,11,12,13, 14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38, 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63, 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88, 89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116},“