且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

工作表更改事件粘贴值后不起作用

更新时间:2023-01-22 14:56:17

/ p>

Try this

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo Whoa
    Application.EnableEvents = False

    If Target.Columns.Count > 1 Then GoTo LetsContinue

    If Not Intersect(Target, Columns(9)) Is Nothing Then
        Dim aCell As Range

        For Each aCell In Target
            aCell.Offset(, -1).Value = aCell.Value * aCell.Offset(, 2)
        Next
    End If

LetsContinue:
    Application.EnableEvents = True
    Exit Sub
Whoa:
    MsgBox Err.Description
    Resume LetsContinue
End Sub