Share via

clipboard data changed

Anonymous
2019-06-19T17:54:11+00:00

Hello,

I hope someone can help me here.

I have an Excel workbook where users enter data and this generates a code. Then there is a button to copy the code to the clipboard with the following function: 

Sub CopyCode()

   Sheets("Code").Range("Hexcode").Copy

End Sub

The idea is that the code than gets pasted into a different tool, and after that the user presses a reset button that resets all the data to zero. However when clicking the reset button before pasting the code in the other tool, the information stored on the clipboard changes to all zeroes as well, so then the code that would be pasted is just 0000000000 instead of what was copied to the clipboard, while the script for the reset function has no link at all to the clipboard. 

Does anyone know what I can do to let the data on the clipboard remain unchanged to prevent losing the code if someone accidentally clicks reset before pasting it?

Any help would be appreciated.

Thanks,

Pascal

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Vijay A. Verma 104.9K Reputation points Volunteer Moderator
    2019-06-20T09:48:01+00:00

    My suggestion should not take 3 to 4 lines to achieve.

    I don't know what is the root cause. However, in VBA, if you copy something in clipboard, that has a chance to be overwritten by another copy operation.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2019-06-20T09:35:40+00:00

    Hello Vijay,

    thank you for your reply.

    So if I understand you correctly, your suggestion is that at the time the copy button is clicked that I also add the code to a sort of backup field, and leave that unchanged when the reset button is clicked, and then add a secondary copy option to copy from that field, which I can probably manage to do with the same button and a simple yes/no flag.

    It sounds achievable as a workaround, but a lot of work to fix something which shouldn't actually be happening.

    I hope there is an easier solution possible.

    Thanks,

    Pascal

    Was this answer helpful?

    0 comments No comments
  3. Vijay A. Verma 104.9K Reputation points Volunteer Moderator
    2019-06-19T19:35:27+00:00

    Hi PascalStil

    Greetings! I am Vijay, an Independent Advisor. I am here to work with you on this problem.

    As a workaround, you can store the copied value in a cell in a hidden sheet. Then you pick up that value from there and paste anywhere.

    Do let me know if you have any more question or require further help.

    Was this answer helpful?

    0 comments No comments