Solved

Lock cells across workbook after data entry

Posted on 2016-09-30
10
66 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 20

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 20

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 20

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 20

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 20

Accepted Solution

by:
Roy_Cox earned 500 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 20

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 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