|
- Sub 汇总()
- On Error Resume Next '出错执行下一步
- Dim i, i2, i3, 最后一行行号
- 最后一行行号 = ActiveSheet.UsedRange.Row + ActiveSheet.UsedRange.Rows.Count
- i2 = 最后一行行号
- For i = 最后一行行号 To 2 Step -1
-
- If LCase(Trim(Range("a" & i).Value)) = "c" Then '清空空格及转换大小写
- i3 = Application.WorksheetFunction.Sum _
- (Range(Cells(i2, 2), Cells(i + 1, 2)))
- Range("a" & i).Offset(0, 1) = i3
- i2 = i - 1
- ElseIf LCase(Trim(Range("a" & i).Value)) = "b" Then
-
-
- i3 = Application.WorksheetFunction.Sum _
- (Range(Cells(i2, 2), Cells(i + 1, 2)))
- Range("a" & i).Offset(0, 1) = i3
- i2 = i - 1
- ElseIf LCase(Trim(Range("a" & i).Value)) = "a" Then
-
-
- i3 = Application.WorksheetFunction.Sum _
- (Range(Cells(i2, 2), Cells(i + 1, 2)))
- Range("a" & i).Offset(0, 1) = i3
- End If
- Next
- End Sub
复制代码 |
|