Macro is preventing copy-paste

Shanaya2009

New Member
Joined
Mar 11, 2021
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone,

I have a table with a lot of data and formulas which is causing the calculations to run slow.
Because of that, I have a macro for manual calculation in workbook and a macro to run automatic calculation in active sheet, if I change anything.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Calculate
End Sub

This change is preventing copy-paste function in the active sheet.
How can I solve this?

I tried to insert Application.CutCopyMode = True, but it's not working.

Thanks for any help.
 
Last edited by a moderator:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Excel has an uncanny habit of clearing the clipboard when a macro runs. When there is a change in the worksheet, Worksheet_Change runs and executes ActiveSheet.Calculate which clears the clipboard.

What you can do is check if there is data in the clipboard and if there is, then do not run ActiveSheet.Calculate.

Try this

VBA Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim var As Variant
   
    '~~> Loop through the clipboard formats
    For Each var In Application.ClipboardFormats
        '~~> There is data in clipboard
        If var > -1 Then Exit Sub
    Next var
   
    ActiveSheet.Calculate
End Sub

To know more about formats see the MS Documentation XlClipboardFormat enumeration (Excel)
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top