|
simpman 发表于 2014-12-21 00:21
早,发现一个问题,品号只能一个个输入,两个以上一粘,单价就出不来。
程序对多格同时编辑无效(有限制一句)
如果确需同时多格编辑时(如复入)
代码改为:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If ActiveSheet.Name = "汇总" And ActiveSheet.Name = "价格表" Then Exit Sub
Dim ar, a&, b&, j&, k&, n&
a = Target.Row: n = Target.Count: b = a + n - 1
ar = Array(11, 2, 3, 4, 8)
For k = a To b
If Target.Column = 7 Then
For j = 0 To UBound(ar)
If d.exists(Cells(k, 7).Value) Then Cells(k, ar(j)) = d(Cells(k, 7).Value)(j)
Next
Cells(k, 12) = Cells(k, 8)
If Cells(k, 7) = "" Then Cells(k, 5) = "": Cells(k, 9) = ""
ElseIf Target.Column = 5 Then
If Cells(k, 5) = "" Then
Cells(k, 9) = "": Cells(k, 13) = ""
Else
Cells(k, 9) = Cells(k, 5) * Cells(k, 8)
Cells(k, 13) = Cells(k, 5) * Cells(k, 12)
End If
ElseIf Target.Column = 11 Then
If d.exists(Cells(k, 11).Value) Then Cells(k, 12) = d(Cells(k, 11).Value)(4)
If Cells(k, 5) <> "" Then Cells(k, 13) = Cells(k, 5) * Cells(k, 12)
If Cells(k, 11) = "" Then Cells(k, 13) = ""
End If
Next
End Sub |
|