|
本帖最后由 feiaoli 于 2022-3-6 09:49 编辑
通过mmwwdd老师、wowo000老师不厌其烦的大力的无私帮助,做了一个很好用的流水账,仅此分享表达对两位老师的感激之情!
同时也感谢其他老师的无私帮助!
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- If FilterMode = True Then
- arr = Sheet1.UsedRange
- r = UBound(arr)
- If Cells(r, 5).HasFormula = False Then
- With Cells(r + 1, 1)
- .Value = "合 计"
- .Resize(1, 4).HorizontalAlignment = xlHAlignCenterAcrossSelection
- End With
- Range("E" & r + 1 & ":F" & r + 1).FormulaR1C1 = "=subtotal(9,r2c:r[-1]c)"
- Range("G" & r + 1).FormulaR1C1 = "=SUBTOTAL(109,R2C5:RC[-2])-SUBTOTAL(109,R2C6:RC[-1])"
- Range("A" & r + 1 & ":G" & r + 1).Interior.ColorIndex = 44
- End If
- End If
- If FilterMode = False Then
- arr = Sheet1.UsedRange
- r = UBound(arr)
- If Cells(r, 5).HasFormula = True Then
- Cells(r, 1).EntireRow.Delete
- End If
- End If
- r = Cells(Rows.Count, 1).End(xlUp).Row
- C = Cells(1, Columns.Count).End(xlToLeft).Column
- Range("G" & r).FormulaR1C1 = "=SUBTOTAL(109,R2C5:RC[-2])-SUBTOTAL(109,R2C6:RC[-1])"
- End Sub
复制代码
|
|