Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VBA在循环中引用公式中的节时中断_Vba_Excel_Excel 2007 - Fatal编程技术网

VBA在循环中引用公式中的节时中断

VBA在循环中引用公式中的节时中断,vba,excel,excel-2007,Vba,Excel,Excel 2007,我目前正在使用一个包含以下条件的循环 For Each Cell In Range("A3:A1000").Cells If Cell.Value = "Existing" And IsEmpty(Cell.Offset(0, 7).Value) Then Cell.Offset(0, 7).Value = "X" Cell.Offset(0, 5).Formula = "=VLookup(RC[-1],Customers!R2:T5000,2,FALSE)"

我目前正在使用一个包含以下条件的循环

For Each Cell In Range("A3:A1000").Cells
     If Cell.Value = "Existing" And IsEmpty(Cell.Offset(0, 7).Value) Then
     Cell.Offset(0, 7).Value = "X"
     Cell.Offset(0, 5).Formula = "=VLookup(RC[-1],Customers!R2:T5000,2,FALSE)"
     Cell.Offset(0, 6).Formula = "=VLookup(RC[-2],Customers!R2:T5000,3,FALSE)"
     End If
Next Cell

除了一个例外,只要将公式附加到单元格,第二个值就变成客户$2:$2:'T5000'。有人知道为什么会发生这种情况吗?

您混合了
.Formula
.formula1c1
属性,并为每个属性更正了语法。尝试以下几行:

Cell.Offset(0,5).FormulaR1C1 = "=VLookup(RC[-1],Customers!R2C18:R5000C20,2,FALSE)"
Cell.Offset(0,6).FormulaR1C1 = "=VLookup(RC[-2],Customers!R2C18:R5000C20,3,FALSE)"