2017-09-27 178 views
0

我正在製作一個Excel宏,但不斷收到運行時錯誤1004:在這段代碼中。Excel宏:運行時錯誤1004

FormulaR1C1 = "=IFERROR(""VLOOKUP(""(Active.Workbook.Sheets(""Sheet1(CT)"").Range(""E2"")),Application.Goto Workbooks(""Cycle time list of products.xls"").Sheets(""Sheet1"").Range(""A1:C300"")"",""3"",""FALSE"")"",0)" 
+0

的可能的複製[運行時錯誤1004](https://stackoverflow.com/questions/24652537/run-time-error-1004) – waka

回答

4

你有太多的",你沒有正確串接使用VBA公式:

.Formula = "=IFERROR(VLOOKUP(" & ActiveWorkbook.Sheets("Sheet1(CT)").Range("E2").Address(0,0,,1) & "," & Workbooks("Cycle time list of products.xls").Sheets("Sheet1").Range("A1:C300").Address(1,1,,1) & ",3,FALSE),0)" 
+2

或者在公式中直接使用表格名稱:'Selection.Formula =「= IFERROR(VLOOKUP('Sheet1(CT)'!$ E $ 2,'[產品週期時間表.xls] Sheet1'!$ A $ 1:$ C $ 300,3,FALSE),0)「' –

+0

所以我做了這個,現在說:運行時錯誤'9':下標超出範圍 –

+0

@ Mads.R檢查表單名稱和工作簿mes拼寫正確。 –