Copy to Clipboard in VBA no longer working

markkuznetsov1

New Member
Joined
Sep 23, 2023
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hello, this is my first macro based workbook so please answer in laymans terms if possible. This workbook basically is button based that produces a "next number" and spits out date/time and user who clicked as well. It also should copy the produced number to clipboard to manually enter in another program. I have a separate sheet "AuthUsers" to type in users that are authorized to both, use in read/write and click the button. Everything worked flawlessly today until after I tried to protect the sheet. I first protected the auth users column with Review: Protect : Allow Edit Range (also added myself and another user to not require password to change cells). Then I protected the number generating sheet but unprotected after I realized it protects the button as well. The last thing I did before I noticed it would not copy to clipboard is put the protect/unprotect code in VBA. I put that code as a comment to test and it still will not copy. Lots of information but I wonder if the protection is the reason for the copy not to work anymore as it is the only thing I changed.
 

Attachments

  • button 1 code.png
    button 1 code.png
    78.9 KB · Views: 45
  • button 1 code 2.png
    button 1 code 2.png
    32.7 KB · Views: 47

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Another way to copy a cell's text to the Windows clipboard can be found in this link...

I am not sure if it will solve your protection issue. For that, I usually unprotect early and protect late in the code. I do not recall having any issues like you are describing.

Hope that helps,

Doug
 
Upvote 0
Another way to copy a cell's text to the Windows clipboard can be found in this link...

I am not sure if it will solve your protection issue. For that, I usually unprotect early and protect late in the code. I do not recall having any issues like you are describing.

Hope that helps,

Doug
Thank for the input Doug, ended up just finding an older copy and re-doing it...now it works with protection. Freak error I suppose in this case
 
Upvote 0
Hello, this is my first macro based workbook so please answer in laymans terms if possible. This workbook basically is button based that produces a "next number" and spits out date/time and user who clicked as well. It also should copy the produced number to clipboard to manually enter in another program. I have a separate sheet "AuthUsers" to type in users that are authorized to both, use in read/write and click the button. Everything worked flawlessly today until after I tried to protect the sheet. I first protected the auth users column with Review: Protect : Allow Edit Range (also added myself and another user to not require password to change cells). Then I protected the number generating sheet but unprotected after I realized it protects the button as well. The last thing I did before I noticed it would not copy to clipboard is put the protect/unprotect code in VBA. I put that code as a comment to test and it still will not copy. Lots of information but I wonder if the protection is the reason for the copy not to work anymore as it is the only thing I changed.

***Edit , solved...copy to clipboard code needs to go after the save code...that's what cancelled it
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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