Copy Paste Not working after adding macro calculate function

Copper Contributor

I have a macro to create a function that gives the sum of values with particular cell color in a selected range of columns. For that macro to run whenever the cell color is changed in the range of columns, I added the following code to the sheet, but that is not allowing me to copy-paste one cell to another within the range of columns - G:K. Please advise.

 

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Not Intersect(Target, Range("G:K")) Is Nothing Then
        ActiveSheet.Calculate
    End If

End Sub

1 Reply

@Vishal88 Change your code like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Application.CutCopyMode = xlCopy Or Application.CutCopyMode = xlCut Then Exit Sub
    If Not Intersect(Target, Range("G:K")) Is Nothing Then
        ActiveSheet.Calculate
    End If
End Sub