View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Neil Neil is offline
external usenet poster
 
Posts: 173
Default Protecting sheet temporarly

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

"Imran" wrote:

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