【发布时间】:2014-08-07 17:25:30
【问题描述】:
Sub TryAgain()
Dim A As Range '~ I will put the result in this column, A
Dim B As Range
Dim C As Range '~ [B-C] is the what I need
Dim onecell As Range
Dim twocell As Range
Set B = Range("C2", Range("C2").End(xlDown)) 'log prices of Z over time
Set C = Range("D2", Range("D2").End(xlDown)) 'log prices of WPC over time
Set A(1) = B.Value - C.Value
End Sub
我一直在努力解决这个烦人的问题。
这是两列之间的简单减法运算,
所以我想做的是进行减法运算'CELL-BY-CELL'
但是!我不想将结果放入单元格(待参考)或创建任何其他工作表。
所以,我想将减法结果(即C2-D2,C3-D3 ...)直接分配给一个名为A的变量(这应该是一列),
不在工作表单元格上记录并引用单元格,但这显然很难通过。
还有其他方法吗?
提前非常感谢!
【问题讨论】:
标签: excel vba operator-keyword subtraction