'class module:- clscustomer
Public z As Integer
Public rng As Range
Public c As Range
Public Sub sum(x As Integer, y As Integer)
z = x + y
'error here
c.Offset(0, 2).Value = z \\error hereva
End Sub
答案 0 :(得分:0)
即使你设置了c,你也只能获得第一行的总和,你必须把你的代码放在一个循环中;你可以尝试在执行你想要完成的动作时录制宏;或者使用更基本的代码...
With ActiveSheet
.Range("C2").Formula = "=SUM(A1,B1)"
.Range("C2:C20").FillDown
End With