[英]Sum Specific Rows Of Used Range
I know how to find the last row, and add a SUM()
to that, but how do I SUM(G+H)
in column O
for each row of the used range? 我知道如何找到最后一行,并为其添加一个
SUM()
,但是对于使用范围的每一行,如何在列O
中使用SUM(G+H)
?
I would use this to get the last row and sum columns, how could this be converted to sum rows? 我会使用它来获取最后一行和总和列,如何将其转换为总和行?
With ws
If Application.WorksheetFunction.CountA(.Cells) <> 0 Then
LastRow = .Cells.Find(What:="*", _
After:=.Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Else
LastRow = 1
End If
.Range("C" & LastRow + 1).FormulaR1C1 = "=SUM(R[-" & LastRow & "]C:R[-1]C)"
.Range("C" & LastRow + 1 & ":M" & LastRow + 1).FillRight
End With
Something like this would get G
+ H
in column O
: 像这样的东西会在
O
列中得到G
+ H
:
Sub testme()
Dim l_counter As Long
For l_counter = 1 To 100
ActiveSheet.Cells(l_counter, 15).FormulaR1C1 = "=RC7+RC8"
Next l_counter
End Sub
Just make sure that you change the 100
to a variable, in your case, LastRow 只需确保将
100
更改为变量(在您的情况下为LastRow)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.