Excel user form interface

M

Maddoktor

I am hoping someone can help me with the following problem. I have a form as
the interface for an excel spreadsheet where a user enters the data into the
form which in turn sends it to the spreadsheet. Unfortunately the worksheet
is unprotected and user can therefore manipulate the data or formulas.

I was wondering if anyone can help me with any lines of code that i will
need to incorporate into my code so that the worksheet can be protected
without causing errors when the user form is invoked. One way I believe may
work is that the worksheet is initially protected. Once the user clicks on
the button that invokes a macro to display the form then the worksheet
should then be unprotected (user cannot manipulate the worksheet as form has
focus), and then once the OK button is pressed to close the form then the
worksheet should then be protected.

Thank you in advance for any ideas or help that you can offer me.
 
H

Harald Staff

Hi

Try

Sub Tester()
ActiveSheet.Unprotect ("*****")
UserForm1.Show
ActiveSheet.Protect ("*****")
End Sub


HTH. Best wishes Harald
 
Top