|
本帖最后由 zuoxiaobin 于 2018-8-25 16:49 编辑
麻烦老师帮忙调试一下程序
目的就是:1、手动输入营业情况表后;2、自动汇总;3、自动汇总统计老师的营业情况。
谢谢!
Sub 自动合计()
[A1].Formula = "=rand()"
ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas).Clear
ActiveSheet.UsedRange.Find("姓名").Select
Lr = Selection.End(xlDown).Row
If Lr > 3 And Lr < 1000 Then
Range("b4:b" & Lr) = [b4].Value
Range("C4:C" & Lr).FormulaR1C1 = "=Counta(R4C4:RC4)"
Range("I4:I" & Lr).FormulaR1C1 = "=Sum(RC5:RC8)"
Cells(Lr + 3, "D") = "合计"
Range(Range("E" & Lr + 3), Range("K" & Lr + 3)).FormulaR1C1 = "=Sum(R4C:R[-3]C)"
Range("O4:O" & Lr).FormulaR1C1 = "=Sum(RC[-5]:RC[-4],-RC[-6])"
End If
Range("B1:O" & Lr + 3).Rows.AutoFit
Range("A1:O" & Lr + 3).Columns.AutoFit
End Sub
Sub 统计()
ActiveSheet.UsedRange.Find("合计").Select
SR = Selection.Row
Range("E3:I3").Copy Range("E" & SR + 2)
lm = Range("M" & SR + 2).End(xlDown).Row
Range("M3:M" & SR - 3).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("M" & SR + 2), Unique:=True
Range("E" & SR + 3).Resize(lm - SR - 2, 5).FormulaR1C1 = "=SUMPRODUCT((R4C:R" & SR - 3 & "C)*(R4C13:R" & SR - 3 & "C13=RC13))"
End Sub
|
|