Solved

Lock cells across workbook after data entry

Posted on 2016-09-30
10
53 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 17

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 17

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
 

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 17

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 17

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 17

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 17

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now