我想将公式自动填充到最后一行。如果我只选择一列它工作正常,但如果我选择包含行和列的更大范围,该函数不会填充第一行或第一列。有谁知道为什么?
第一个代码片段像它应该的那样工作:
If Not Intersect(Target, Range("V1")) Is Nothing Then
wsPlan.Range("V4").Formula = "=IFERROR(INDEX(Data!$I:$I,MATCH(VALUE(ROW()&V$2),Data!$A:$A,0)),"""")"
Range("V4").AutoFill Destination:=Range("V4:V" & Range("E" & Rows.Count).End(xlUp).Row)
End If
第二个省略了第 V 列和第 4 行,有什么想法吗?
If Not Intersect(Target, Range("V1")) Is Nothing Then
wsPlan.Range("V4").Formula = "=IFERROR(INDEX(Data!$I:$I,MATCH(VALUE(ROW()&V$2),Data!$A:$A,0)),"""")"
Range("V4").AutoFill Destination:=Range("V4:X" & Range("E" & Rows.Count).End(xlUp).Row)
End If
一次写出所有的公式。AutoFill 不能很好地处理两个方向的填充。
If Not Intersect(Target, Range("V1")) Is Nothing Then
with wsPlan
'write all of the formulas into V:X
.Range(.cells(4, "V"), .cells(.rows.count, "E").end(xlup).offset(0, 19)).Formula = _
"=IFERROR(INDEX(Data!$I:$I, MATCH(VALUE(ROW()&V$2), Data!$A:$A, 0)), text(,))"
end with
End If
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句