Sub lookup_macro()
Dim X As Integer
Dim erow As Integer
Dim ecol As Integer
erow = Sheets("sheet1").Range("a" & Rows.Count).End(xlUp).Row
erow1 = Sheets("sheet2").Range("a" & Rows.Count).End(xlUp).Row
ecol = Sheets("sheet2").Cells(1,Columns.Count).End(xlToLeft).Column
For X = 2 To erow1
For Y = 2 To ecol
Cells(X,Y) = Application.WorksheetFunction.VLookup(Range("a" & X),Sheets("sheet1").Range("a1" & ":f",erow),_
Application.WorksheetFunction.Match(Cells(1,Y),Sheets("sheet1").Range("a1:f1"),0),0)
Next Y
Next X
End Sub
我正在尝试将 VLOOKUP()
与 MATCH()
函数结合起来。
但它给我一个带有 * 标记行的错误。谁能帮我解决这个问题?