Excel中自动按照货物名称实现结余累计的示例
来源:互联网 发布:ajax post提交数据 编辑:程序博客网 时间:2024/04/29 01:33
日常生活中,购入消耗货物常运用Excel进行相关统计,能不能实现自动统计出某类货物的结余情况呢?能。示例如下:
Private Sub Worksheet_Change(ByVal Target As Range)Dim Lj, jy, Ljgr, LjxhIf Target.Row <= 1 Then Exit SubIf Target.Column < 3 Or Target.Column > 7 Then Exit SubIf Target.Count > 2 Then Exit Sub'判断输入值非负数If Target.Value < 0 And Target.Column > 3 And Target.Column < 6 Then MsgBox "内容不能为负值!" Target.Select Target.Value = ""End IfIf Target.Row = 2 Then Cells(2, 6) = Cells(2, 4) - Cells(2, 5)End IfIf Target.Row > 2 Then Ljgr = 0 Ljxh = 0 For i = 2 To Target.Row - 1 If Cells(i, 3) = Cells(Target.Row, 3) Then Ljgr = Ljgr + Cells(i, 4) Ljxh = Ljxh + Cells(i, 5) End If Next '判断消耗是否大于以往结余 If (Target.Value > Ljgr - Ljxh + Cells(Target.Row, 4)) And Target.Column = 5 Then MsgBox "消耗过多了!" Target.Value = "" Target.Select End If Cells(Target.Row, 6) = Ljgr - Ljxh + Cells(Target.Row, 4) - Cells(Target.Row, 5) End IfEnd Sub
0 0
- Excel中自动按照货物名称实现结余累计的示例
- Excel 中自动阅卷的实现
- 在PHP中实现按照预定规则自动生成编号的方法
- 名称的秘密:Excel中隐藏着的名称空间
- 在Zf2中实现Controller按照URL自动注册
- 在EXCEL中创建动态的名称
- Excel文件中定义名称的妙处
- EXCEL中定义名称
- 库存中货物超期的天数
- EXCEL中堆积柱型图如何显示累计数…
- json 按照指定的名称排序!
- 累加功能的实现 (累计计算)
- excel中如何实现自动求和?
- php中如何实现将数组中的某个下标的值累计相加
- 工作中遇到的问题(累计)
- EXCEL实现按照奇偶行填充
- VB.Net获取Excel中Sheet的名称
- C#获取Excel中所有的Sheet名称
- 快大三了,该确定专业方向了
- 活动图(Activity Diagram) - 项目分解篇
- 黑马程序员——OC学习总结14-16
- 让我们来嚼makefile: 自动推导功能
- 十八春-张爱玲
- Excel中自动按照货物名称实现结余累计的示例
- 一天比一天差,怎么办喽
- Aspx目标网站入侵之旁注加跨站入侵
- nginx tomcat集群配置实现无痛重启服务教程
- 循环-15. 统计素数并求和(20)
- 硬件工程师笔试题
- C#泛型的协变和抗变
- 循环-16. 猴子吃桃问题(15)
- leetcode -day29 Binary Tree Inorder Traversal & Restore IP Addresses