我正在嘗試使用動態範圍的索引匹配公式在工作表「報告」中分配單元格E8。範圍是從表「數據」運行時錯誤5,無效的過程或調用參數
我已經找到最後一行(LR)和最後一列(lc)。在最後一行發生 運行時間錯誤:細胞(「E8」)式=「= ....」
這是代碼:
Sub report()
Dim LR As Long, lc As Long, first As Long, proxy As String
Sheets("Data").Select
'Finding the first filled cell by moving down from A1
first = Sheets("Data").Range("A1").End(xlDown).Row
'The first row has column headers: Name, ID number, etc... SO I assign it to the next row where the first data entry is
first = first + 1
LR = Sheets("Data").Range("A" & first).End(xlDown).Row
lc = Sheets("Data").Range("A" & first).End(xlToRight).Column
Sheets("Report").Select
proxy = "=IFERROR(INDEX(Data!$A$10:" & Cells(LR, lc).Address & ",MATCH(Report!$C$3,Data!$A$10:" & Cells(LR, 1).Address & ",0),MATCH(Report!$C8,Data!A$9:" & Cells(9, lc).Address & ",0)),'N/A')"
Cells("E8").Formula = proxy
End Sub
不應該是'Data!$ A $「&first&」:「&...'而不是'Data!$ A $ 10:」&...'? – Jeeped