Protecting sheet temporarly

  • Thread starter Thread starter Imran
  • Start date Start date
I

Imran

Hello ALL

I Have written a Macro which opens a dialog and
ask user to enter some data. After recving the
data, I enter this data to the sheet.

Now How do i restrict user to enter only data
thru my dialog. Since if user tries to modify
or delete the data dierctly from the xls sheet,
it will be a problem. Can we protect the sheet?

When user enter the data in the dialog, we will
remove the protection and once he closes the dialog
we will enable the protection. Can v do this?

Thanks In Advance

Reg
 
I would be inclined to do the opposite, i.e. Protect your sheet for normal
usage, and unprotect it when you want to manipulate the data.

If you set a protection password for your sheet, you can unprotect your
sheet with the code line:

ActiveSheet.Unprotect Password:="Password"

and re-protect it with the line

ActiveSheet.Protect Password:="Password"

You will of course need to make sure that the sheet you want to protect /
Unprotect is the current active sheet.

If you decide to protect your sheet, something like the following code would
work:

VariableName = Inputbox ("Enter Data")
ActiveSheet.Unprotect Password:="Password"
Range ("A1").Select
ActiveCell = VariableName
ActiveSheet.Protect Password:="Password"

HTH

Neil
www.nwarwick.co.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top