disable cells editing

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

Hi;
I'd like to prevent the user to edit the content of my cells in the
sheet. This is easy, however I want these same cells to be editable
progamatically by my macros. And this is my problem, if I lock the
cell, how can i modify them in the macros ?

thx
 
Hi;
I'd like to prevent the user to edit the content of my cells in the
sheet. This is easy, however I want these same cells to be editable
progamatically by my macros. And this is my problem, if I lock the
cell, how can i modify them in the macros ?

Unprotect the sheet by VBA code before you edit it:

Sub EditProtectedSheet()

If Sheet1.ProtectContents Then
Sheet1.Unprotect "MyPassword"
End If

Sheet1.Cells(1, 3).Value = "Input2"

Sheet1.Protect "MyPassword"

End Sub
 
thx, but in that case, anyone who can open a macro code can actually
see the password and modify the data, how can i prevent this to happen ?
 
Sam

ALT + F11 to get to VB Editor.

CTRL + r to open Project Explorer.

Select your project/workbook.

Right-click and VBA Project Properties.

Select Protection tab and follow your nose.

Workbook must be saved at that point.


Gord Dibben Excel MVP
 

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