[英]Excel VBA - Sum function
I'm trying to calculate the sum of my columns (column I). 我正在尝试计算列的总和(列I)。 From 1 to the last record in I it has.
从1到我的最后一条记录。 When I record a macro I get this as output, but this is gibberish to me.
当我记录一个宏时,我将其作为输出,但这对我来说是胡言乱语。
ActiveCell.FormulaR1C1 = "=SUM(R[-11]C:R[-4]C)"
I found another topic and there they said 我找到了另一个话题,他们说
LastRow = .Range("I" & .rows.Count).End(xlUp).row
Range("I"&LastRow) = "SUM(I1:I...)"
Except in my case, I can't figure how to enter the lastrow of I in it. 除了我的情况,我无法确定如何在其中输入我的最后一行。 All help is welcome :)
欢迎所有帮助:)
There are two ways of referencing a cell - 'R1C1' and 'A1'. 引用单元格有两种方式-'R1C1'和'A1'。 The former works like co-ordinates, with a relative number of rows (R) and cells (C).
前者的工作原理类似于坐标,具有相对数量的行(R)和单元格(C)。
The other reference style refers to the cell name on the sheet - B6, F67 etc. 另一种参考样式是指工作表上的单元格名称-B6,F67等。
Let's say you want to put your Sum()
in cell B1
and LastRow
has a value of 6: 假设您要将
Sum()
放在单元格B1
, LastRow
的值为6:
ActiveSheet.Range("B1") = "=Sum(I1:I" & LastRow & ")"
Would insert the following function in cell B1
: 将在单元格
B1
插入以下功能:
=SUM(I1:I6)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.