Password protect parts of worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have macros on a spreadsheet/worksheet that does some calculations.
I have protected certain columns that have formulas and that seems to be ok
until I want to press my macro button and have it do additional calculations
or print.
But since I have the worksheet protected, how can I also 'unprotect' the
macro button to all this?
i.e. Column E is protected and I set the Tools/Protection/worksheet password
protected. I have several macro buttons that does various things. When I
click on these buttons, I get an error stating that they can not be run
because the worksheet is protected.
How can I protect my formulas and allow the macro buttons to work?
(e-mail address removed) or (e-mail address removed)
thx
dwebb
 
Hi ddwebb

You can unprotect your sheet in the code
and protect it again after your code is ready.

But I like this way.

Protect your worksheets with code like this
Copy this in the Thisworkbook module.
The macro's will be working now

Private Sub Workbook_Open()
Dim sh As Worksheet
Application.ScreenUpdating = False
For Each sh In ThisWorkbook.Worksheets
sh.Protect "ABCD", , , userinterfaceonly:=True
Next sh
Application.ScreenUpdating = True
End Sub
 
Do I have to mention the name of the worksheet or the columns I want
protected? For a dude that is not a programmer, I am muddling thru this and
trying to learn.
What is ABCD, is that a value I need to change?
Or ThisWorkBook?
dougw
 
Names: My worksheet name is: CheckIn
Columns want protected: L, T, U, and V
thx
dw
 
Hi

You lock/unlock the cells you want the normal way.
This event will protect all worksheets for you in the workbook.
It use userinterfaceonly in the protect line to keep your macro's working.

ABCD = the password of the worksheets(you can change it

For a dude that is not a programmer, I am muddling thru this

Try it first on a test workbook

Right click on the Excel icon next to File in the Worksheet menu bar
Choose view code
Paste this event there
Alt-q to go back to Excel

Save/close/reopen the workbook
 
Thanks. That seems to be working.
Now to put into production and let the staff find a problem.
dw
 

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