+ Reply to Thread
Results 1 to 2 of 2

How do I protect a sheet if there is an error on a userform?

  1. #1
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Holland, MI
    MS-Off Ver
    Excel 2007
    Posts
    110

    How do I protect a sheet if there is an error on a userform?

    Hi All,
    Currently, when I open a userform, I use the userform initialize() command to unportect a sheet and then userform terminate() to re-protect those sheets. Is there an alternative command that I can use so that the sheets are re-protected if there is a error on the userform?

    This is the code I use to unprotect the sheeet. This works properly.
    Please Login or Register  to view this content.

    This is what I use to re-protect the sheet once the userform is terminated. This works properly.
    Please Login or Register  to view this content.
    This is what I was trying to use but didn't work.
    Please Login or Register  to view this content.
    Thanks

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: How do I protect a sheet if there is an error on a userform?

    Hi, jfoerch,

    have you tried using the parameter UserInterfaceOnyl:=True when protecting the sheet (this would allow macro code to run bzt no action from the normal interface)? Please mind that this is a volatile setting and is not saved with teh file.

    Maybe use
    Please Login or Register  to view this content.
    Alternative may be to have an error handler in the code with On Error GoTo Handle_err and protect the sheet in there again before ending the UF.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ 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