PDA

View Full Version : [SOLVED] VBA Unprotect not working properly



Sir Babydum GBE
12-29-2017, 05:45 PM
I have code that pastes (xlValues) information from a worksheet into my target worksheet.

When I tested it, it worked perfectly

But in the non-test world the sheet is protected.

Of course in the protected sheet the code fails ("PasteSpecial method of range class failed")

Fair enough, So before the paste execution, I write into the code to unprotect the sheet. and re-protect it after the paste. But I still get the error! If I manually unprotect it and then run the macro, all is fine again! ("PasteSpecial method of range class failed")

What am I missing?

Sir Babydum GBE
12-29-2017, 06:16 PM
Well, I fixed it by moving the unprotect instruction to the start of the code. I don't know why that should make a difference. But it did

Jan Karel Pieterse
12-31-2017, 08:19 AM
Perhaps unprotecting the sheet emptied the clipboard?