使用范围的特定行总和
我知道如何find最后一行,并添加一个SUM()
,但如何SUM(G+H)
在列O
使用范围的每一行?
我会用它来得到最后一行和总和列,这怎么可能被转换为总和行?
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
像这样的东西会在列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
只要确保将100
更改为一个variables,就你的情况而言,LastRow