回復 6#myleoyes
幾種方法你參考看看
Sub Ex1_1() '容易懂
Dim r As Long
r = [K65536].End(xlUp).Row + 1
Range("K" & r) = Sheet4.[I1]
Range("L" & r) = "=K" & r & "-K" & r - 1 & "+" & Sheet2.[AZ19] & "-" & Sheet2.[AZ20]
End Sub
Sub Ex1_2() '公式中位址用address取就可以了
With [K65536].End(xlUp).Offset(1, 0)
.Value = Sheet4.[I1]
.Offset(0, 1).Value = "=" & .Address(0, 0) & "-" & .Offset(-1, 0).Address(0, 0) & "+" & Sheet2.[AZ19] & "-" & Sheet2.[AZ20]
End With
End Sub
Sub Ex1_3() '不保留公式算出來也是一樣的
With [K65536].End(xlUp).Offset(1, 0)
.Value = Sheet4.[I1]
.Offset(0, 1).Value = .Value - .Offset(-1, 0).Value + Sheet2.[AZ19] - Sheet2.[AZ20]
End With
End Sub作者: myleoyes 時間: 2012-11-30 21:11