Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
excel上的VBA-使用vlookup的结果作为匹配的标准_Excel_Vba_Match_Vlookup - Fatal编程技术网

excel上的VBA-使用vlookup的结果作为匹配的标准

excel上的VBA-使用vlookup的结果作为匹配的标准,excel,vba,match,vlookup,Excel,Vba,Match,Vlookup,我使用vlookup从表2中的表1中查找匹配项。现在,我想使用查找的结果来查找该特定字符串的行号 Private Sub CommandButton1_Click() On Error Resume Next Dim BPP_Row As Long Dim BPP_Clm As Long Dim result As String Dim num As String Table1 = Sheet1.Range("B6:C44") Table2 = Sheet3.Range("B6:B147") T

我使用vlookup从表2中的表1中查找匹配项。现在,我想使用查找的结果来查找该特定字符串的行号

Private Sub CommandButton1_Click()
On Error Resume Next
Dim BPP_Row As Long
Dim BPP_Clm As Long
Dim result As String
Dim num As String
Table1 = Sheet1.Range("B6:C44")
Table2 = Sheet3.Range("B6:B147")
Table3 = Sheet1.Range("C1:C44")
BPP_Row = Sheet3.Range("D6").Row
BPP_Clm = Sheet3.Range("D6").Column
For Each cl In Table2
 result = Application.WorksheetFunction.VLookup(cl, Table1, 2, False)
 num = Application.Match(""" + result + """, Table3, 0)
 Sheet3.Cells(BPP_Row, BPP_Clm).Formula = "=""" + result + """ + """ + num + """"
 BPP_Row = BPP_Row + 1
 result = ""
 num = ""
Next cl
MsgBox "done"
End Sub
设法把它修好了

Private Sub CommandButton1_Click()
On Error Resume Next
Dim BPP_Row As Long
Dim BPP_Clm As Long
Dim result As String
Dim num As String
Table1 = Sheet1.Range("B6:C44")
Table2 = Sheet3.Range("B6:B147")
Table3 = Sheet1.Range("C1:C44")
BPP_Row = Sheet3.Range("D6").Row
BPP_Clm = Sheet3.Range("D6").Column
For Each cl In Table2
 result = Application.WorksheetFunction.VLookup(cl, Table1, 2, False)
 num = Application.WorksheetFunction.Match(result, Table3, 0)
 Sheet3.Cells(BPP_Row, BPP_Clm).Formula = "=""" + result + """ + " + num + ""
 BPP_Row = BPP_Row + 1
 result = ""
 num = ""
Next cl
MsgBox "done"
End Sub

为什么不使用Application.WorksheetFunction.Match函数?