0
我需要搜索Excel中Col G中文本的更改,然後將3 Col中的值相加。到目前爲止,這個工作除了總和對x行是靜態的。我需要它在「RowCount」上是動態的,任何幫助都會很棒。我有一兩天的時間。在循環中計算列的總和
Dim iRow As Integer, Tags As Integer
Dim oRng As Range
Dim RowCount As Integer
Set oRng = Range("G2")
iRow = oRng.Row
Tags = oRng.Column
Do
'
If Cells(iRow + 1, Tags) <> Cells(iRow, Tags) Then
Cells(iRow + 1, Tags).EntireRow.Insert Shift:=xlDown
Cells(iRow + 1, Tags).Interior.Color = 65535
Cells(iRow + 1, Tags - 1).Interior.Color = 65535
Cells(iRow + 1, Tags - 2).Interior.Color = 65535
Cells(iRow + 1, Tags - 3).Interior.Color = 65535
Cells(iRow + 1, Tags - 4).Interior.Color = 65535
Cells(iRow + 1, Tags - 5).Interior.Color = 65535
Cells(iRow + 1, Tags - 6).Interior.Color = 65535
Cells(iRow + 1, Tags).Value = Trim(Cells(iRow, Tags - 6) & " " & (Cells(iRow, Tags)) & " Totals")
Cells(iRow + 1, Tags - 6).Value = Array("Totals")
Cells(iRow + 1, Tags - 1).Select
ActiveCell.FormulaR1C1 = "=SUM(R[-40]C:R[-1]C)" <<<<<<<<< the -40 I want to be the Integer of 「RowCount」
Cells(iRow + 1, Tags - 2).Select
ActiveCell.FormulaR1C1 = "=SUM(R[-40]C:R[-1]C)" <<<<<<<<< the -40 I want to be the Integer of 「RowCount」
Cells(iRow + 1, Tags - 3).Select
ActiveCell.FormulaR1C1 = "=SUM(R[-40]C:R[-1]C)" <<<<<<<<< the -40 I want to be the Integer of 「RowCount」
iRow = iRow + 2
RowCount = 0
Else
iRow = iRow + 1
RowCount = RowCount + 1
End If
' 「= SUM(R [」 &行數與「C:[R [-1] C)「' –