ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protecting sheet temporarly (https://www.excelbanter.com/excel-programming/324005-protecting-sheet-temporarly.html)

Imran[_2_]

Protecting sheet temporarly
 
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



Neil

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





All times are GMT +1. The time now is 07:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com