如何使用FormulaR1C1循环

huangapple go评论70阅读模式
英文:

How to loop with FormulaR1C1

问题

I'm trying to loop in VBA with FormulaR1C1, but when I put the "R4C(15+i)" the result breaks on the front.

The VBA Formula I'm placing:

For i = 1 To 20
  Range("O5").Offset(0, i) = "=SumIfs(C10,C2,R5C15,C6,R4C(15+i))"
Next

The result I'm getting on the front:
It's in Spanish, but the important part is the part that doesn't work at the end "@W$4(15+@i)".

=SUMAR.SI.CONJUNTO($J:$J,$B:$B,$O$5,$F:$F,@W$4(15+@i))
英文:

Im trying to loop in vba with FormulaR1C1, but when I put the "R4C(15+i)" the result breaks on the front.

The VBA Formula im placing:

For i = 1 To 20
 Range("O5").Offset(0, i) = "=SumIfs(C10,C2,R5C15,C6,R4C(15+i))"
Next

The result Im getting on the front:
Its in spanish, but the important part is the part that dosent work at the end "@W$4(15+@i)".

=SUMAR.SI.CONJUNTO($J:$J,$B:$B,$O$5,$F:$F,@W$4(15+@i))

答案1

得分: 0

尝试这样:

对于 i 从 120
    范围("O5").偏移(0, i) = "=SumIfs(C10,C2,R5C15,C6,R4C" + (15+i) + ")"
英文:

Try it like this:

For i = 1 To 20
    Range("O5").Offset(0, i) = "=SumIfs(C10,C2,R5C15,C6,R4C" & (15+i) & ")"
Next

huangapple
  • 本文由 发表于 2023年6月27日 20:54:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76565076.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定