[英]VBA Excel change column inside of formula
I have a formula within a loop.我在循环中有一个公式。
For x = 0 To dataLastColumn - 1
wsModel.Cells(startCell + 3, 2 + x).Formula = "=(($B$34*B33)/B30)*B31"
Next x
For each x I'd like to change the column for the next one.对于每个 x,我想更改下一个的列。 For example: if x = 1 than my desired formula would be -
例如:如果 x = 1,那么我想要的公式将是 -
wsModel.Cells(startCell + 3, 2 + 1).Formula = "=(($B$34*C33)/C30)*C31"
if x = 2如果 x = 2
wsModel.Cells(startCell + 3, 2 + 2).Formula = "=(($B$34*D33)/D30)*D31"
Is there a way to change columns like that?有没有办法改变这样的列?
I Try This One Its Working我试试这个它的工作
sModel.Cells(startCell + 3, 2 + x).Resize(, dataLastColumn-1).Formula = "=(($B$34*B33)/B30)*B31"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.