|
本帖最后由 naive薇 于 2015-11-25 13:03 编辑
求在VBA中编辑乘法公式
详情见附件
用公式有什么不妥吗?
在原代码上加了一小段。 - Private Sub Worksheet_Change(ByVal T As Range)
- Dim D, rng
- If T.Row > 7 And T.Row < 14 And T.Column = 2 Then
- If T.Text = "" Then
- Application.EnableEvents = False
- T.Offset(, 1).Resize(1, 2) = ""
- Application.EnableEvents = True
- Else
- With Sheets("信息表")
- Set D = .Range("A:A").Find(T.Text, , , 2)
- rng = D.Offset(, 1).Resize(1, 2)
- End With
- Application.EnableEvents = False
- T.Offset(, 1).Resize(1, 2) = rng
- Application.EnableEvents = True
- End If
- '''''''''''''''''''新增部分
- ElseIf Not Intersect(T, [f8:j13]) Is Nothing Then
- Application.EnableEvents = False
- r = T.Row
- If Cells(r, "F") * Cells(r, "J") > 0 Then Cells(r, "H") = Cells(r, "F") * Cells(r, "J") '单价=备注*单位
- Cells(r, "I") = Cells(r, "G") * Cells(r, "H") '金额=数量*单价
- [I14] = Application.WorksheetFunction.Sum([I8:I13])
- Application.EnableEvents = True
- End If
- End Sub
复制代码
|
|