新增文章
文章标题
分类
C#
云星空
K3 BOS
K3 功能
用友
Oracle
python
SQL
MySql
PHP
HTML
script
windows
Access
影视后期
财务
服务
生活
内容
Private Sub Worksheet_Change(ByVal Target As Range) '【单元格 数值变化时】 On Error Resume Next If Target.Column = 33 Then aMax = 1000 aRow = Target.Row '当前单元格.行号 aCol = Target.Column '当前单元格.列号 aPageRow = Cells(1, aCol).Value '当前列 第1行 的值 aValue = Target.Value '当前单元格.值 If aValue = "合计" Then Exit Sub Else aMod = aValue - Int(aValue / aPageRow) * aPageRow '取余数 If aMod = 0 Then Rows(aRow).EntireRow.Offset(1).Resize(2).Insert '当前行 下移1行 插入2行 aBottom = 1 For i = aRow To aMax aValue = Cells(i, aCol).Value '取得 单元格数值 If aValue = "合计" Then aBottom = i Exit For '退出循环 End If Next i Set aRanges = Union(Rows(aBottom), Rows(aBottom + 1)) '设置 区域 aRanges.EntireRow.Select '选中区域 Selection.Copy '复制 Cells(aRow + 1, 1).Select '选中单元格 ActiveSheet.Paste '粘贴 Application.CutCopyMode = False '取消复制 Cells(aRow + 2, aCol).Select '选中单元格 End If End If End If End Sub
返回
保存