+ Reply to Thread
Results 1 to 14 of 14

Protected Sheet and Locked Cells Compromised!

  1. #1
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Protected Sheet and Locked Cells Compromised!

    Hello All,

    Some "CLever" guy messed up my Program.

    From an UnProtected Sheet he Selected a Range and clicked on Copy. He then Entered "Desing Mode" via the Developer Tab in the Ribbon, and then Activated the Protected Sheet. Then He exited "Design Mode" and Pasted Values via a CommandButton into the Locked Cells of the Protected Sheet, erasing my formulas!!!

    The Code for the CommandButton is:

    Please Login or Register  to view this content.
    Within the Protected Sheet itself it works fine, but,

    How can I improve on the code, for this not to happen?

    Many Thanks
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Protected Sheet and Locked Cells Compromised!

    I can't seem to replicate the approach as it keeps giving me a run-time 1004 error (which is what should happen to prevent pasting ontop of protected cell). Can you upload an example?
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Protected Sheet and Locked Cells Compromised!

    Unfortunately, as you have discovered, Excel *IS NOT* a secure platform. There are some good hacking tools a "clever" user could acquire to crack your protection.
    However, you might try locking your VBA Project (but *MAKE SURE* you don't loose the password.

    The problem with Excel is that users have the option to enable macros or not, If they choose to not enable them your code is defeated.
    You could use a separate workbook at a "gateway" to test if macros are enabled and then open the real workbook when the code is enabled.

    If they don't enable the code, then they don't get access to the workbook.

    You might also consider hiding the developer tab when the workbook is opened.
    See the YouTube video from MacroMountain.Com

    As far as your code goes, you could, at the onset, test if sheet protection is on or off. If off, display a message and exit the macro, skipping all the code that does the copy/paste.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Protected Sheet and Locked Cells Compromised!

    Thank you aboutsetta,

    Please allow me a moment to prepare a Sample

  5. #5
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Protected Sheet and Locked Cells Compromised!

    Here is the copy I used, you can see if maybe I am doing it correctly.
    Attached Files Attached Files

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Protected Sheet and Locked Cells Compromised!

    Hi aboutsetta,

    You are Spot-On!

    It works in your WorkBook, but not mine! Please bear with me for a day or so. I promise to look into this, and report back to you!

    Thank you so much!

    @Palmetto,

    Thank you as well, for your contribution. I shall keep yoy also posted on this issue.

    Thanks guys!!!

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Protected Sheet and Locked Cells Compromised!

    Hi Guys,

    As promised, my report back.

    The issue is that I want to be able to use my Code to Paste what I have Selected and Copied in one Active Sheet. And that works just fine!. However, as I have explained the issue about some "Clever" Guy in my first Post, it should NOT be possible to Paste from another Sheet using his method since the VBA project is re-activated when he exits Design Mode and the Sheet he is Copying to is Protected. My VBA Project is also PassWord Protected.

    I have replicated the problem on the WorkBook aboutsetta gave me. See Attachment.

    In my Actual WorkBook I have to Unprotect the actual Sheet in question in order to perform some tasks, and then Protect it again. All via VBA. This seems where the problem starts. It is as if VBA does not Protect the WorkBook the Same way as Protection via the Ribbon does.

    Thank you for your time !
    Attached Files Attached Files
    Last edited by Winon; 06-04-2012 at 08:05 AM. Reason: Wrong Code in WB

  8. #8
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Protected Sheet and Locked Cells Compromised!

    Hi Winon,

    I still can't reproduce your problem in Excel 2010, but I did notice something interesting which could lead to a solution. When in Design Mode, viewing the other sheets does not trigger the Worksheet_Activate Event. When outside of Design mode, viewing an object (e.g. worksheet) either by manually clicking on the worksheet tab or through vba triggers the event code. Not sure how to disable the Design Mode but might be the culprit.

    Hope this helps.

    abousetta

  9. #9
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Protected Sheet and Locked Cells Compromised!

    Hi abousetta,

    Once again, thank you for looking at this. I have re-uploaded the WorkBook and elaborated in my last Post with an explaination of what I think the problem could be.

    Would you mind to have a look at that and the WorkBook again please?

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Protected Sheet and Locked Cells Compromised!

    If you want to avoid 'clever' users:
    Only use userforms for any user interaction, make the workbook invisible (application.visible=false) or make it an addIn, protect the VBAproject with a password.



  11. #11
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Protected Sheet and Locked Cells Compromised!

    Quote Originally Posted by Winon View Post
    In my Actual WorkBook I have to Unprotect the actual Sheet in question in order to perform some tasks, and then Protect it again. All via VBA. This seems where the problem starts. It is as if VBA does not Protect the WorkBook the Same way as Protection via the Ribbon does.
    I have seen this problem before. The thread was kind of old but I remember that protecting the worksheet via vba could be unprotected via vba without a password even though a password was provided during the sheet protection. There may be problems with sheet protection via vba or specific functions that are protected differently between the two methods.

  12. #12
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Protected Sheet and Locked Cells Compromised!

    Hi snb,

    Its been a while. Very nice to hear from you as well! The WorkBook is just over 4Mb, and the Sheet Range where the User May Select or Highlight a Selection may span from Column C to O and 909 Rows down. I cannot see how to accomplish this via a UserForm. My VBA Project is protected with a PassWord.

    Any other ideas?

  13. #13
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Protected Sheet and Locked Cells Compromised!

    Hi abousetta,

    You guys are just GREAT. Thank you for all your time! Not IF but WHEN I find a solution, I shall let you know.

  14. #14
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Protected Sheet and Locked Cells Compromised!

    You could restrict the scrollarea(manually or by VBA)
    Use an application.inputbox.
    Check the result of this inputbox:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1