Worksheet Change event not working after pasting values

I have a code in Worksheet_Change

If a column 9 is updated then the column 8 will be automatically populated by multiplying with col 9 and col 11.

But when the user pastes the values in the column, the change event does not work correctly. Only the first cell in the Col 8 gets updated.

How can I overcome from this?

Answers


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

Need Your Help

Configuring resiliency settings Entity Framework 6.02

c# sql .net database entity-framework

I'm trying to configure resiliency settings for EF6.02. I have an application which in one point of execution writes a log entry to database. The application is not depending on the SQL-server so i...