我在Excel中有表格,想要总结列中的所有单元格" count"并且"重新进货",然后在列中重写结果" count"本身。接下来,宏将清除"重新进货"中的所有现有值。柱。
非常感谢您的帮助!
答案 0 :(得分:0)
如上所述,在请求下一个问题之前,我会请你稍微研究一下。但我喜欢人们开始使用VBA的想法,所以这就是:
Sub test()
'First you dimension two variables as Ranges
Dim cnt As Range
Dim rstckd As Range
'You assign the Ranges to the variable
Set cnt = Range("A2:A4")
Set rstckd = Range("B2:B4")
'To store the results you initialize an array to store the sums
Dim results()
'You redimension the results array to the number of entries in your table
ReDim results(1 To cnt.Rows.Count)
'You loop over your table and sum the values from count and restocked
For i = 1 To cnt.Rows.Count
results(i) = cnt(i, 1) + rstckd(i, 1)
Next i
'You write the array to the range count and delete the values in restocjed
cnt = Application.Transpose(results)
rstckd.Clear
End Sub