我想要將兩個Excel建立連結
例如:Excel A的A1欄位值=Excel B的D1欄位值
我用下面的方式寫,出現錯誤
想請問是哪邊有問題呢??可以這樣寫嗎?
For i = 7 To 16
Windows("Test.xls").Activate
Range("C" & i).Select
ActiveCell.FormulaR1C1 = "='["mfgquery_ww26_L" & i & ".xls"]DAY 1'!R25C11"
Range("D" & i).Select
ActiveCell.FormulaR1C1 = "='["mfgquery_ww26_L" & i & ".xls"]DAY 1'!R4C14"
Next i
1.加了一個檔案路徑
2.公式內容些許調整
試試看可不可用
<pre class="c" name="code">
Sub TEST()
filePath = "C:\Test\Excel\"
Windows("Test.xls").Activate
For I = 7 To 16
Range("C" & I).Select
ActiveCell.FormulaR1C1 = "='" & filePath & "[mfgquery_ww26_L" & I & ".xls]DAY 1'!R25C11"
Range("D" & I).Select
ActiveCell.FormulaR1C1 = "='" & filePath & "[mfgquery_ww26_L" & I & ".xls]DAY 1'!R4C14"
Next I
End Sub