|
楼主 |
发表于 2015-4-8 18:12
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
jpj123 发表于 2015-4-8 17:35
详见附件
非常感谢!试过应该是这个效果。另还是这个表,想请大师帮忙看下这段代码,可否优化一下,希望“汇总”表能自动加上边框线,再次感谢!!!
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Sh.Name = "填单" And Target.Address = "$B$1" And Target.Value <> "" Then
Dim brr(1 To 1, 1 To 3)
Application.EnableEvents = False
Worksheets("填单").Copy after:=Worksheets("填单")
With ActiveSheet
.Name = [b1].Value
brr(1, 1) = .[b1]: brr(1, 2) = .[j1]: brr(1, 3) = .[j2]
End With
With Worksheets("汇总")
.Activate
x = .Cells(Rows.Count, "c").End(3).Row
.Rows(x).Clear
With .Cells(x, "c")
.Resize(, 3) = brr
.Offset(1) = "汇总"
.Offset(1, 1) = Application.Sum(Range("d3:d" & x))
.Offset(1, 2) = Application.Sum(Range("e3:e" & x))
End With
End With
End If
Application.EnableEvents = True
End Sub
|
|