我正在清理一個文件,我試圖SUM值一起,但總和總是等於零。我的代碼給出正確的範圍,並執行正確的格式...只是不能得到的總和,顯示什麼,但0VBA Excel:插入SUM函數,但它總是等於零
Sub AddBlankRows()
'
Dim iRow As Integer, iCol As Integer
Dim oRng As Range
Dim fRow As Integer
Set oRng = Range("e2")
iRow = oRng.Row
iCol = oRng.Column
fRow = iRow
Do
'
If Cells(iRow + 1, iCol) <> Cells(iRow, iCol) Then
Cells(iRow + 1, iCol).EntireRow.Insert shift:=xlDown
iRow = iRow + 1
Range("k" & iRow).Font.Bold = True
Range("k" & iRow).Value = "Total"
Range("l" & iRow).Font.Bold = True
Range("l" & iRow).Formula = "=sum(l" & CStr(fRow) & ":l" & CStr(iRow) & ")"
iRow = iRow + 1
fRow = iRow
Else
iRow = iRow + 1
End If
'
Loop While Not Cells(iRow, iCol).Text = ""
'
End Sub
嗨,即時通過行'範圍(「l」和iRow)得到的印象.Formula =「= sum(l」&CStr(fRow)&「:l」&CStr(iRow)&「)」他們試圖總結自己,你確定他們是正確的行和列是總結? – lewisthegruffalo