[英]Excel VBA - Adjusting a formula to let VBA loop it
I have following formula 我有以下公式
=IF(Matching_Sheet!F3=0;"";Matching_Sheet!F3)
= IF(Matching_Sheet!F3 = 0;“”; Matching_Sheet!F3)
I want to let VBA fill in the B column of a sheet with this formula adjusted to the respective column number. 我想让VBA在此表格的B列中填充此公式,并将其公式调整为相应的列号。 I have tried this
我已经试过了
For x = 2 To destMaxRow
Range("$B$" & x).FormulaLocal = "=IF(Matching_Sheet!$F$=0;" & x & Chr(34) & Chr(34) & ";Matching_Sheet!$F$)" & x
Next
Unfortunately, this form apparently has a mistake but I cannot figure out what it is. 不幸的是,这种形式显然有一个错误,但我无法弄清楚它是什么。
Any help would be appreciated. 任何帮助,将不胜感激。 Thanks in advance.
提前致谢。
Not sure, try this 不确定,试试这个
For x = 2 To destMaxRow
Range("$B$" & x).FormulaLocal = "=IF(Matching_Sheet!$F$" & x & "=0;" & Chr(34) & Chr(34) & ";Matching_Sheet!$F$" & x & ")"
Next
Which I think could be shortened to (obviating need for a loop) 我认为可以缩短为(无需循环)
Range("$B$2:B" & destMaxRow).FormulaLocal = "=IF(Matching_Sheet!$F2=0;" & Chr(34) & Chr(34) & ";Matching_Sheet!$F2)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.