我有更多格式问题
我正在查看具有索引#(C列)和帐号#(E列)的交易表。我需要汇总整个索引中的所有条目,然后才能累计帐户中的所有条目。我有一些我正在玩的代码,但我无法弄清楚如何在获取索引总数后对帐户条目进行总计。
Sub TotalIndex()
'
Dim iRow As Integer, iCol As Integer
Dim oRng As Range
Dim fRow As Integer
Dim lRow As Integer
Set oRng = Range("c4")
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("j" & iRow).Font.Bold = True
Range("j" & iRow).Value = "Total"
Range("k" & iRow).Font.Bold = True
lRow = iRow - 1
Range("k" & iRow).Value = "=sum(k" & CStr(fRow) & ":k" & CStr(lRow) & ")"
iRow = iRow + 1
fRow = iRow
Else
iRow = iRow + 1
End If
'
Loop While Not Cells(iRow, iCol).Text = ""
'
End Sub
Sub TotalAccount()
'
Dim iRow As Integer, iCol As Integer
Dim oRng As Range
Dim fRow As Integer
Dim lRow As Integer
Set oRng = Range("e4")
iRow = oRng.Row
iCol = oRng.Column
fRow = iRow
Dim laRow As Long
Dim laCol As Long
laRow = Cells.Find(What:="*", _
After:=Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Do
'
If Cells(iRow + 1, iCol) <> Cells(iRow, iCol) Then
Cells(iRow + 1, iCol).EntireRow.Insert shift:=xlDown
iRow = iRow + 1
Range("j" & iRow).Font.Bold = True
Range("j" & iRow).Value = "Total"
Range("k" & iRow).Font.Bold = True
lRow = iRow - 1
Range("k" & iRow).Value = "=sum(k" & CStr(fRow) & ":k" & CStr(lRow) & ")"
iRow = iRow + 1
fRow = iRow
Else
iRow = iRow + 1
End If
'
Loop While Not Cells(iRow, iCol).Text = ""
'
End Sub
我将代码分为两个功能。一个总数指数,然后另一个功能是&#34;尝试&#34;总计每个索引内的帐户。
有什么建议吗?