【发布时间】:2016-02-25 12:57:35
【问题描述】:
我在总结 VBA 中数组的特定条目时遇到问题。我举个例子说明我的矩阵是什么样的(我们称矩阵为“startMatrix”)
Date ticker value
2005.01 200 1000
2005.01 300 2222
2005.01 400 2000
2005.02 200 1100
2005.02 300 3000
2005.02 400 5555
在 VBA 中,矩阵的读取方式如下:
startMatrix(1,1) = 2005.01
startMatrix(1,2) = 200
startMatrix(1,3) = 1000
startMatrix(2,1) = 2005.01
startMatrix(2,2) = 300
....
startMatrix(6,3) = 5555
所以如果代码是 200 或 300,我想总结每个日期的值并保存这个新数组(我们称之为 finalMatrix)。那么 finalMatrix 应该是这样的:
Date Value
2005.01 3222
2005.02 4100
finalMatrix 最后在 VBA 中应如下所示:
finalMatrix(1,1) = 2005.01
finalMatrix(1,2) = 3222
finalMatrix(2,1) = 2005.01
finalMatrix(2,2) = 4100
我不太习惯这种操作,所以我非常非常感谢您的帮助。 提前谢谢你,祝你有美好的一天 埃利奥
【问题讨论】:
标签: arrays vba excel if-statement sum