|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
你的源代码如下:
On Error GoTo errout
Application.EnableEvents = False
orow = Target.Row
ocol = Target.Column
If orow > 3 And ocol > 5 And ocol < 16 Then
For y = 6 To 15
sum_row = sum_row + Cells(orow, y)
Next
Cells(orow, 16) = sum_row
End If
Application.EnableEvents = True
errout:
稍作更改如下:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
orow = Target.Row
ocol = Target.Column
If orow > 3 And ocol > 5 And ocol < 16 Then
For y = 6 To 15
On Error GoTo errout
sum_row = sum_row + Cells(orow, y)
Next
Cells(orow, 16) = sum_row
End If
Application.EnableEvents = True
Exit Sub
errout: MsgBox "你输入的值是" & Cells(orow, y) & "不是数字!"
Application.EnableEvents = True
End Sub
请楼主试试看! |
|