Dim cuttent_columns As Integer
Dim care_repeat As Integer Private Sub Workbook_Open()
Dim i As Integer
Dim j As Integer
'确定cuttent_columns的值
For i = 1 To 100
If Cells(1, i) = "" Then
For j = i To 100
If Cells(1, j) = "" Then Else
cuttent_columns = j - 1
'MsgBox "init cuttent_columns"
'MsgBox cuttent_columns
Exit Sub
End If
Next
End If
Next End Sub Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
On Error Resume Next '跳过异常
Application.ScreenUpdating = False '关闭屏幕更新 If care_repeat = 1 Then
care_repeat = 0
'MsgBox "防止正反馈"
Exit Sub
End If If Target.Row > 51 Then Exit Sub 'MsgBox "cuttent_columns"
'MsgBox cuttent_columns
'MsgBox "Target.Row"
'MsgBox Target.Row
'MsgBox "Target.Target.Column"
'MsgBox Target.Column Dim null_flag As Integer
Dim i As Integer
null_flag = 0 If Cells(Target.Row, 2) = 0 Or Cells(Target.Row, 2) = "" Then Else
For i = 2 To cuttent_columns
If Cells(Target.Row, i) = "" Then
care_repeat = 1
Cells(Target.Row, i) = Cells(Target.Row, 2)
care_repeat = 1
Cells(Target.Row, 2) = 0
null_flag = 1
Exit For
End If
Next If null_flag = 0 Then
cuttent_columns = cuttent_columns + 1
care_repeat = 1
ActiveSheet.Columns(cuttent_columns).Insert
care_repeat = 1
Cells(Target.Row, cuttent_columns) = Cells(Target.Row, 2)
care_repeat = 1
Cells(Target.Row, 2) = 0
End If
End If '计算总和
Dim littel_total As Integer
Dim littel_total_num As Integer
Dim big_total_num As Integer
littel_total = cuttent_columns + 1
littel_total_num = 0
big_total_num = 0 '计算小总和
For i = 3 To cuttent_columns
littel_total_num = littel_total_num + Cells(Target.Row, i)
Next
care_repeat = 1
Cells(Target.Row, littel_total) = littel_total_num '判断
If Cells(Target.Row, littel_total) > Cells(53, 2) Then
care_repeat = 1
Cells(Target.Row, littel_total + 1) = "金额超过阈值"
Else
care_repeat = 1
Cells(Target.Row, littel_total + 1) = ""
End If '计算大总和
For i = 2 To 51
big_total_num = big_total_num + Cells(i, littel_total)
Next
care_repeat = 1
Cells(52, littel_total) = big_total_num Application.ScreenUpdating = True '恢复屏幕更新 End Sub

  

最新文章

  1. WCF分布式开发必备知识(1):MSMQ消息队列
  2. python 中类方法@classmethod
  3. 初学java之StringBuffer类的常用方法
  4. 极客DIY:如何构建一台属于自己的基站
  5. activiti自定义流程之整合(四):整合自定义表单部署流程定义
  6. MySQL优化技巧之四(数据库设计中的一些技巧)
  7. MySQL定期分析检查与优化表
  8. Zend Studio的配置和使用
  9. line-height属性详解
  10. C#之Action和Func的用法
  11. 【工具】Idea GenerateAllSetter
  12. 自制操作系统Antz(14)——实现内置编程语言(词法解析器)
  13. iOS AppIcon尺寸
  14. 读书笔记--SQL必知必会--常用MySQL(MariaDB)命令及示例
  15. bat输出重定向
  16. k8s-rabbitmq-(一)集群部署
  17. <魔鬼投资学>读书笔记
  18. # WinForm关闭窗体确认
  19. PostMan 使用Interceptor 发送带cookie的请求一直loading
  20. python OSError: [Errno 22] Invalid argument: 'D:\\crawle\x01.html1'

热门文章

  1. jQuery入门教程-文档操作方法
  2. html from表单异步处理
  3. xsxsxsxsxsxsxsxs
  4. eureka注册中心wro.css wro.js 404
  5. linux 统计代码行数
  6. mysql_DCL_grant/revoke
  7. mybatis有结果返回null
  8. SQL的一对多,多对一,一对一,多对多
  9. spring事务——try{...}catch{...}中事务不回滚的几种处理方式(转载)
  10. vue构造器注册UI组件