?
Solved

Lock cells across workbook after data entry

Posted on 2016-09-30
10
Medium Priority
?
74 Views
Last Modified: 2016-10-07
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
0
Comment
Question by:StephanieFoster
  • 6
  • 4
10 Comments
 
LVL 22

Expert Comment

by:Roy Cox
ID: 41824682
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.
0
 

Author Comment

by:StephanieFoster
ID: 41824848
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.
0
 
LVL 22

Expert Comment

by:Roy Cox
ID: 41825154
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
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:StephanieFoster
ID: 41826665
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.
0
 
LVL 22

Expert Comment

by:Roy Cox
ID: 41826685
It was erroring on the CheckBoxes. There is one on Actions sheet but it is not recognised I'll check your code againn
0
 

Author Comment

by:StephanieFoster
ID: 41827176
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
0
 
LVL 22

Expert Comment

by:Roy Cox
ID: 41827471
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
0
 
LVL 22

Accepted Solution

by:
Roy Cox earned 2000 total points
ID: 41828381
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.
0
 

Author Comment

by:StephanieFoster
ID: 41834273
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.
0
 
LVL 22

Expert Comment

by:Roy Cox
ID: 41834708
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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question