我正在尝试在一系列单元格上使用 vlookup 函数,该函数在其他工作表中查找值。但是,我不断收到一个运行时错误,上面写着“应用程序定义或对象定义错误”。
ActiveSheet.Range("$A$1", Selection.End(xlDown)).RemoveDuplicates Columns:=1, _
Header:=xlYes
'In Summary Tab
Range("A1").CurrentRegion.Select
nRows = Selection.Rows.Count
' Places column headers in "Summary" tab
For iCounter = 2 To Sheets.Count
Sheets(iCounter).Select
Range("A1").CurrentRegion.Select
nCols = Selection.Columns.Count
For iColumn = 2 To nCols
Sheets(iCounter).Select
If (WorksheetFunction.IsNumber(Cells(2, iColumn)) = "TRUE") Then
Cells(1, iColumn).Select
Selection.Copy
Sheets("Summary").Select
ActiveCell.Offset(0, 1).PasteSpecial
Application.CutCopyMode = False
ActiveCell.Offset(1, 0).Select
ActiveCell.Resize(nRows - 1, 1).Select
Selection.Formula = "=vlookup(B2," & _
Range(sheets(icounter).selection).Address","& icolumn",false)"
End If
Next
Next
我还尝试将 vlookup 公式编辑为此,(其他一切都相同):
Selection = Application.WorksheetFunction.VLookup( _
"B2", Sheets(iCounter).CurrentRegion.Select, iColumn, False)
但这会产生错误 438“对象不支持此属性或方法”
甚至尝试将 vlookup 编辑为此但再次收到 1004 错误:
选择 = Application.WorksheetFunction.VLookup("B2",Sheets(iCounter).Range(Cells(1, 1), Cells(nCols, nRows)), iColumn, False)