|
手动插入行或列就卡不动了,有触发Worksheet_Change,哪位有空帮忙看看指点一下,谢谢!
- Private Sub Worksheet_Change(ByVal Target As Range)
- On Error Resume Next
- Dim c, c1, c3
- Dim arr As Integer, arr1 As Integer, arr3 As Integer
- Dim mrow As Integer, mrow1 As Integer
- Dim brng As String, crng As String, brng1 As String, crng1 As String, brng2 As String
-
- Application.ScreenUpdating = False
- mrow = Target.Row
- If Target.Column <> 6 Then Exit Sub
- If Target.Row < 3 Then Exit Sub
- mrow = Target.Row
- Set c1 = Sheet3.[B:B].Find(Target.Value, , , 1) '模具清单
- Set c11 = Sheet8.[A:A].Find(Target.Value, , , 1) '单价表
- If Application.CountIf(Sheet3.[B:B], Target.Value) >= 1 Then
- Target.Offset(0, -1) = c1.Offset(0, -1)
- c1.Offset(0, 1).Copy Target.Offset(0, 6) ' 模具编号
- Target.Offset(0, 7) = c1.Offset(0, 2) '材料
- Target.Offset(0, 8) = c1.Offset(0, 3) '宽
- Target.Offset(0, 9) = c1.Offset(0, 4) '步距
- Target.Offset(0, 10) = c1.Offset(0, 5) '厚
- Target.Offset(0, 11) = c1.Offset(0, 6) '产品单重
- Target.Offset(0, 19) = c1.Offset(0, 8) '存货编码
- Target.Offset(0, 21) = c1.Offset(0, 7) '存货编码
- Target.Offset(0, 14) = c1.Offset(0, 9) '产品名称
- Range("Ae" & mrow) = c1.Offset(0, 10) '产品规格
- Range("s" & mrow) = c1.Offset(0, 11) '后工序处理
- Range("I" & mrow) = c11.Offset(0, 1) '单价
- Range("Ad" & mrow) = (Now()) '入单时间
- End If
-
- '------------------------------------------------------------------库存
- Set c = Sheet4.[A:A].Find(Target.Value, , , 1)
- If Application.CountIf(Sheet4.[A:A], Target.Value) >= 1 Then
- Target.Offset(0, 3) = c.Offset(0, 2)
- c.EntireRow.Delete
-
- End If
- '------------------------------------------------------------------输入公式
- brng = Range("h" & mrow) '订单数量
- crng = Range("Q" & mrow) '产品单重
- jrng = Range("j" & mrow) '每小时产量
- frng = Range("AD" & mrow) '已领重量
- Range("R" & mrow).Formula = "=" & "(" & brng & "*" & crng & ")" & "*" & 1.05
- Range("A" & mrow).Formula = "=" & "(" & brng & "*" & crng & ")" & "*" & 1.05 & "-" & frng
- Range("c" & mrow).Formula = "=" & "h" & mrow & "/ " & "j" & mrow
- brng2 = Range("V" & mrow) '累计生产
- brng4 = Range("R" & mrow) '实际用料重量
- brng3 = Range("AA" & mrow) '产品净重
- crng2 = Range("AB" & mrow) '产品净重用料
-
- Range("AB" & mrow).Formula = "=" & "(" & brng3 & "*" & brng & ")"
- Range("aC" & mrow).Formula = "=" & "(" & brng4 & "-" & crng2 & ")"
-
- Application.ScreenUpdating = True
- Set c4 = Sheet16.[B:B].Find(Target.Value, , , 1)
- If Application.CountIf(Sheet16.[B:B], Target.Value) >= 1 Then
- 品质异常查看表.项目.Text = c4
- 品质异常查看表.客户.Text = c4.Offset(0, -1)
- 品质异常查看表.日期.Text = c4.Offset(0, 1)
- 品质异常查看表.登记员.Text = c4.Offset(0, 2)
- 品质异常查看表.问题描述.Text = c4.Offset(0, 3)
- 品质异常查看表.Show
- c4.EntireRow.Delete
-
- End If
-
- '----------------------------------------------------------------------清除
- If IsEmpty(Cells(mrow, 6)) Then
- Cells(mrow, 6).EntireRow.Delete
- End If
-
- Application.ScreenUpdating = True
- Application.EnableEvents = True
- Exit Sub
- End Sub
复制代码
|
|