VBA编码,查找和匹配功能

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() 函数结合起来。 但它给我一个带有 * 标记行的错误。谁能帮我解决这个问题?

sunonxg 回答:VBA编码,查找和匹配功能

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/4402.html

大家都在问