2

When I use (some code here).copy destination:=(some code there). It will still prompt for protection issues on cells. Basically it just won't let my code runs.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
4 Leave Cover
  • 1,248
  • 12
  • 40
  • 83

2 Answers2

13

The status UserInterfaceOnly:=TRUEis unfortunately not stored in the file - therefore, if you reopen the file, it will be fully protected. Either use the Workbook_Open event to reapply this protection status - or unprotect and then reprotect the worksheet in your VBA code directly.

See Ozgrid for further details!

Peter Albert
  • 16,917
  • 5
  • 64
  • 88
  • Very lamentable. This means Excel (still in 2021) cannot have VBA operating on protected cells. You can use no password or expose the password in the VBA, but these workarounds somewhat diminish the concept of protection. – DAG Aug 24 '21 at 19:03
  • @DAG Agree. You can password protect your VBA code. Again, not perfect - will deter most users. Anyone really trying to break into your Excel file will succeed with enough persistence regardless of your measures - excel is simply not the right tool if you’re looking for highest data security. – Peter Albert Aug 25 '21 at 09:14
0

I posted one approach to solving this here: https://stackoverflow.com/a/69730040/13307304

Like Peter Albert mentioned, the password itself should not be hardcoded

Dallin Romney
  • 2,276
  • 1
  • 6
  • 5