【发布时间】:2014-11-19 20:52:07
【问题描述】:
我需要编写一个 VBA 函数,该函数将从我的范围中选择所有值,然后将范围的总和显示到单元格 D7 中。到目前为止,这就是我所拥有的。它不能是工作表函数。
Sub Statistics()
'count number of cell in Range
Dim count As Long
Sheets("sheet1").Activate
Range("a1").Select
count = Sheet1.Range("A" & Rows.count).End(xlUp).Row
'output count of cells in Range
Range("D6").Select
ActiveCell.Value = count
'This is where I need to write the sum function and output it to D7
End Sub
【问题讨论】:
-
您求和的范围是多少?在哪一栏?
-
试试
Application.Sum(Range("A:A"))。