|
德茨管理系统.zip
(392.67 KB, 下载次数: 8)
- Private Sub Worksheet_Change(ByVal Target As Range) '就这个过程,出现问题~
- Dim wb1 As Worksheet, wb2 As Worksheet, rag As Range, i As Integer, txt, rags As Range, 行1 As Byte, 行2 As Integer
- Set wb1 = Worksheets("销售单")
- Set wb2 = Worksheets("数据源")
- If Target.Count <> 1 Then Exit Sub
- If Intersect(Target, Range("b7:m16")) Is Nothing Then Exit Sub
- i = wb2.Range("b" & wb2.Cells.Rows.Count).End(xlUp).Row
- If Target.MergeArea.Cells(1, 1) <> "" Then
- txt = Target.MergeArea.Cells(1, 1)
- Else
- End
- End If
- 行1 = Target.Row
- If txt = "" Then End
- Set rags = wb2.Range("b2:b" & i)
- Set rag = rags.Find(what:=txt, LookIn:=xlValues, Lookat:=xlWhole)
- If rag Is Nothing Then
- MsgBox "查无此产品"
- Exit Sub
- Else
- 行2 = rag.Row
- wb1.Range("f" & 行1) = wb2.Range("c" & 行2) '为什么运行到这一步就会中断~
- wb1.Range("i" & 行1) = wb2.Range("d" & 行2)
- wb1.Range("j" & 行1) = wb2.Range("e" & 行2)
- wb1.Range("k" & 行1) = wb2.Range("f" & 行2)
- wb1.Range("l" & 行1) = wb2.Range("g" & 行2)
- End If
- Range("l7").Select
- Selection.Formula = "=if(b7=" & """" & "" & """" & "," & """" & "" & """" & ",i7*k7)"
- Range("l7").Select
- Selection.AutoFill Destination:=Range("l7:l16"), Type:=xlFillDefault
- Range("l7:l16").Select
- End Sub
复制代码 大佬们,帮忙看看哈,运行到 wb1.Range("f" & 行1) = wb2.Range("c" & 行2) 这一步就会从头运行,求解决~
|
|