The FormulaArray
有 255 个字符的限制。
你将不得不分开Formula
and Replace
零件使之再次完整。
参见下面的代码:
Dim Formula As String
Dim fLoc As String
Formula = "=VLOOKUP(MIN(IF(ABS($C$17:$C$42-B5*1000)=MIN(ABS($C$17:$C$42-B5*1000)),IF(ABS($C$17:$C$42-B5*1000)< 500,$C$17:$C$42,))),$C$17:$E$42,3,FALSE)"
fLoc = "'S:\AT Reports\Abhor - Ganganagar\[1 1550 A-B.xls]1 1550 A-B'!$C$17"
With ActiveCell
.FormulaArray = Formula
.Replace "$C$17", fLoc
End With
Edit:
更新您的信息后Formula
这是使用变量执行此操作的方法:
Formula = "=VLOOKUP(MIN(IF(ABS($C$17:$C$42-" & ColToSelect & "5*1000)=MIN(ABS($C$17:$C$42-" & ColToSelect & "5*1000)),IF(ABS($C$17:$C$42-" & ColToSelect & "5*1000)< 500,$C$17:$C$42,))),$C$17:$E$42,3,FALSE)"
fLoc = "'" & initpath & (n / 3 - 2) & " " & freqSheet & " A-B.xls]" & (n / 3 - 2) & " " & freqSheet & " A-B'!$C$17"
With ActiveCell
.FormulaArray = Formula
.Replace "$C$17", fLoc
End With