运行时错误424 excel vba
您好我正在试图写这个macros来做一个查找,所以我没有公式,不断计算和放慢我的工作,但是我不断得到一个运行时错误424:所需的对象。
Sub matchProgram() Dim Mrow As Long Dim Mcol As Long Table1 = Sh1.Range("A1:A20") Table2 = Sh2.Range("A1:B20") Mrow = Sh1.Range("B1").Row Mcol = Sh1.Range("B1").Column For Each cl In Table1 Sh1.Cells(Mrow, Mcol) = Application.WorksheetFunction.VLookup(cl, Table2, 2, False) Mrow = Mrow + 1 Next cl End Sub
你需要Set
对象variables:
Set Table1 = Sh1.Range("A1:A20") Set Table2 = Sh2.Range("A1:B20")
(从技术上说, Table2
将会工作,因为VLOOKUP将会有一个数组)