Lock cells across workbook after data entry

I have a worksheet for data entry.  I found a Visual Basic code that allows me to have a manager be able to unlock the cells they need to enter data on, and will also unlock previously entered information, so if staff make a mistake, supervisors can fix it.  It works perfectly on one sheet.  After some discussion, the managers would like several tabs of data. That way staff don't have to look in three to four different documents to enter data.  I keep getting a run time error when I try to add another cell range to the code.  And then i can't get the check box to ask for a password, etc.  I also have a "button" created so that they can just click that to autofill the dates for them.  The managers are not at all Excel savvy so I'm trying to make it as painless as possible.  I have conditional formatting on, so they know if data has not been entered easily.  I have data validation working well.  I just can't get the code(s) to work across several worksheets because I do not not Visual Basic well.  

These templates will be used for about 180 different individuals, with about 18 managers with their own "templates" for their individuals.  They all have different information that is needed on a monthly basis.

I've uploaded the file in case you want to see what I have done.  Passwords are: for manager password, sheets admin.
Who is Participating?
Roy CoxConnect With a Mentor Group Finance ManagerCommented:
I'm checking your code but I don't believe that any of your code actually works.

You have invented your own event code, you have to use the inbuilt events. You cannot use something like this

Private Sub Workbook_BeforeSave2(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Open in new window

Much of the code is in the wrong modules.

I'll try to understand what you are attempting.
Roy CoxGroup Finance ManagerCommented:
Your code errors immediately.

Private Sub Workbook_Open()
    With Range("InputRange" And "TAInputRange")
        Set ws = .Parent
        Set ChckBx = .Parent.CheckBox1
        ChckBx.Caption = "Manager"
        ChckBx.Value = False
    End With
End Sub

Open in new window

The code using the ranges is incorrectly written

The ranges are on different sheets so Parent is not going to work.

The CheckBoxes do not exist.

The other code needs checking and can be much more efficient.

Can you explain what you are trying to do exactly.
StephanieFosterAuthor Commented:
I would like the manager checkbox to 'unlock' across the entire workbook.  if not then have a check box on each sheet.  I don't want managers to have to  unprotect the sheet because they won't reprotect when they are done editing.  I tried adding the code per worksheet but that didn't work either.
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Roy CoxGroup Finance ManagerCommented:
There are no checkboxes on any sheet.

I've added code to show the userform when the workbook opens. If a manager enters the correct password (password) then each worksheet is unprotected.

It looks to me as if the rest of your code is either unnecessary or will not work though.
StephanieFosterAuthor Commented:
OK, that is strange, I have two buttons on the Actions tab, around the AL/AN column.  One is the manager checkbox and one is a "Fill Dates" button that will fill dates at least on the action spreadsheet.

I will take a look at the template you provided.
Roy CoxGroup Finance ManagerCommented:
It was erroring on the CheckBoxes. There is one on Actions sheet but it is not recognised I'll check your code againn
StephanieFosterAuthor Commented:
for some reason the worksheet 2-2 doesn't accept a password at all.  I can click the X to get out of the password user form and it allows me to edit all the places I don't want staff to edit.  I also need the cells to be locked as soon as the worksheet is saved, only someone with the password can edit.  That way they can't falsify data, or change someone elses data if they are being bad employees.  It works on one spreadsheet (Actions) when there is only the cell range call "InputRange" in the code.  Is there a way to tell it to tell it to look across the workbook vs just the one sheet?  Does .parent need to come out or is there a way to tell .parent that it is all worksheets, workbook, and not just that one worksheet?

Roy CoxGroup Finance ManagerCommented:
I've only added code to the userform, the rest is untouched. As I said it needs checking, I'll have a look at it as soon as I can
StephanieFosterAuthor Commented:
Ok, I was hoping it would be easy for me to fix.  I guess I will stop trying to fix it.  Sorry for the trouble.  They will have to use separate spreadsheets as I warned them to begin with.
Roy CoxGroup Finance ManagerCommented:
I will have a lok at your code but I have been busy and I have had internet issues this week, hopefully my provider has fixed them
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.