Link to home
Start Free TrialLog in
Avatar of StephanieFoster
StephanieFosterFlag for United States of America

asked on

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.
Client-Monthly-Template-dates.xltm
Avatar of Roy Cox
Roy Cox
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Avatar of StephanieFoster

ASKER

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.
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.
Client-Monthly-Template-dates--2-2.xlsm
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.
It was erroring on the CheckBoxes. There is one on Actions sheet but it is not recognised I'll check your code againn
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?

Thanks!!
Stephanie
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
ASKER CERTIFIED SOLUTION
Avatar of Roy Cox
Roy Cox
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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