excel vba - protect sheet with conditions

C

chief

Is it possible to protect a sheet's cells against manual typing, but b
able to input data into the cells through userforms. Basically, I hav
an inventory set up with a main page which opens, which is used t
click on the appropriate button and navigate to a specified userform.
Once there, you enter the number in the textbox and click a (+) or (-
button to edit the inventory count. However, there are some peopl
which have to use the page for adding inventory, and others who ar
only supposed to view the page for quick reference. Is there a way t
protect the cells against people simply viewing the page, and allo
others to edit the cells through this (+/-) method?

Thank
 
H

Harald Staff

Hi

Yes. In an empty workbook, first run one and then the other:

Sub LockUp()
Sheets(1).Protect userinterfaceonly:=True
End Sub

Sub Add()
Sheets(1).Range("A1").Value = _
Sheets(1).Range("A1").Value + 1
End Sub

Unfortunately this kind of protection has to be done by macro code.

HTH. Best wishes Harald
 
Top