Forum Discussion

Marc_Covents's avatar
Marc_Covents
Copper Contributor
Oct 23, 2023

Copy/Paste issue

Hello,

I have a copy/paste issue with an Excel file.
If I try for example to copy the cell I8 (in Sheet KS_2) from file1.xlsm to another Excel file (file2.xlsm) I get an audible error and the Paste button is greyed out.
I can however copy/paste in the file1.xlsm itself.
There is no protection on the Sheets.
The files contain custom VBA code so I enabled macro's.
Both files are located in the same local folder on my hard drive.
I also noticed that if I disable macro's I'm allowed to copy between the Excel files.

File1
https://drive.google.com/file/d/1eGCVYz82wd8voKAWWto2twWKsQ3HOSZY/view?usp=sharing

File2
https://drive.google.com/file/d/1W7ZDNE9mCQXCGf1MPXoFWAiqg_cpA2Xh/view?usp=sharing

Marc

4 Replies

  • Marc_Covents 

    Activate file1.xlsm.

    Press Alt+F11 to activate the Visual Basic Editor.

    Double-click ThisWorkbook in the Project Explorer pane on the left.

    Comment out or delete the code

    Private Sub Workbook_Activate()
        ActiveWindow.DisplayZeros = False
    End Sub
    
    Private Sub Workbook_Deactivate()
        ActiveWindow.DisplayZeros = True
    End Sub

    Switch back to Excel.

    Save the workbook.

    • Marc_Covents's avatar
      Marc_Covents
      Copper Contributor

      HansVogelaar 

      Your solution works. Thank you.
      I added this code because I don't want to see 0 values when the result of a formula is 0
      Do you also have an explanation why this is happening? At first sight this doesn't have anything to do with the copying of data.

      Marc.

      • HansVogelaar's avatar
        HansVogelaar
        MVP

        Marc_Covents 

        Many VBA actions clear Excel's clipboard.

        Changing the value of ActiveWindow.DisplayZeros is one of them, as you have found...