Solved

Protected Stock sheet in Excel

Posted on 2012-04-02
12
232 Views
Last Modified: 2012-04-17
Hi Everyone,

Will try and keep this short.  I work for a multi site company, split into 6 separate divisions, at the end of the month a stock sheet is filled out in excel, this is comprised of the amount of finished/raw/w-i-p stock for each division and is a shared spreadsheet.

All the figures are then transferred into a summary sheet, the problem at the moment is that users are going into there division as and when they want to change there stock figures.

Does anybody have a better idea of doing this?  Is there a way of assigning a button which would look the sheet after the user has inputted the figures?

Any help with this would be greatly appreciated.
0
Comment
Question by:choy77
  • 7
  • 5
12 Comments
 

Author Comment

by:choy77
ID: 37796244
I meant to say *lock not *look
0
 
LVL 6

Expert Comment

by:wshark83
ID: 37796380
here's a way in which you can lock the workbook after certain 30 days...but can easily be modified to lock after submission:

Private Sub Workbook_Open()
    'Range "DateCheck" Is a named cell on XlVeryHiden Sheet.
    If Range("TimeCheck") <> vbNullString Then 'Date has been set.
    'Check date.
    If Range("TimeCheck") < Date - 30 Then 'Expired
    'Your password Code HERE
End If
Else 'Set first Open date
    Range("TimeCheck") = Date
    Me.Save
End If
End Sub

or

This little macro will lock cells B1:B10 when the file is opened if the date
in A1 is more than 2 days earlier than today's date. This macro must be
placed in the workbook module.

Private Sub Workbook_Open()
With Sheets("TheSheetName")
If Date - .Range("A1") > 2 Then
.Range("B1:B10").Locked = True
End If
End With
End Sub
0
 

Author Comment

by:choy77
ID: 37796410
Hi wshark83,

thanks for the info.  How would I assign VB to a button, meaning after the user has inputted there figures, they would then click the button to say its complete and maybe flag up in the summary sheet as complete?

The only way the sheet can be unlocked is with a password?  I hope this makes sense, thanks very much for your help.  It doesnt have to be a sheet which is locked, the button could just lock a portion of cells instead?

Again Thanks.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 

Author Comment

by:choy77
ID: 37796439
P.s.....I am not the most advanced user within excel, I would be most grateful ig you could provide an example spreadsheet :)
0
 
LVL 6

Expert Comment

by:wshark83
ID: 37796577
no probs...

to create a button its easy you can just go to --> view --> toolbars --> Forms and then in the toolbar next to xyz there is grey button which created the button. Select this and then drag and daw the button in an area and it will automatically ask you to assign a macro.

here's a file which does things a bit differently...it protects the whole file from being editited...

also if you want to add password then simply add this line:

ThisWorkbook.Worksheets("Sheet1").Protect Password:="<yourpassword>"
Sample.xls
0
 

Author Comment

by:choy77
ID: 37806410
Hi,

This isn't really how i wanted it, I wanted a summary sheet which would always be locked but would allow the admin to unlock it with a password using a button.  I wanted the other tabs on the sheet to be able to be locked by the user when they have inputted all there data, this can only be locked by the admin person.

I basically want a full workbook with user privileges where only one person can unlock certain things.  I would also like to display a time and date of when the other sheets were locked in the summary page?  Is this possible?  Thanks very much
0
 
LVL 6

Expert Comment

by:wshark83
ID: 37806752
ok here you go...i think i've understood you correctly....

you just need to add the vba in specific tabs --> see attached example
Sample-Password-Control.xls
0
 

Author Comment

by:choy77
ID: 37807038
Hi yes this is similar to what I'm asking for thanks.

Please see attached a sample of what i would like, any help would be greatly appreciated.  Really the sheet should only need one master password, although a password for each division button would be good.  Please let me know if you require any further information
Book1.xlsx
0
 
LVL 6

Accepted Solution

by:
wshark83 earned 500 total points
ID: 37808163
ok i've amended the attached file to meet your requirements...

although there is a flaw or i may have missed something as to how you plan to protect the summary tab ... without this you cannot unlock it....

therefore i've added lock summary button which you can use to enter a password to lock the summary tab....which is hardcode in the vba....

so will need to update all instances of this line...

mypass= "testing" to your desired password

regarding the button text unfortunately you cannot change the text with vba so its best to have a cell with the status as you have it now or have 2 buttons one for lock and another for unlock

also as a VBA Excel user you may want to protect your code so that nobody may modify it and to protect against the loss of intellectual property if people access source code without permission. This is easily achieved in the VBE editor by going to "Tools/VBAProject Properties/Protection". Check the box and enter a password.
Macro-Enabled-File.xlsm
0
 

Author Comment

by:choy77
ID: 37808844
Hi,

Thanks very much for this, really appreciate it.  One thing I noticed is thast if I click the button again to lock a division sheet from the summary it doesnt allow it to.  Would this be better doing it through another button?  Please advise.
0
 
LVL 6

Expert Comment

by:wshark83
ID: 37811193
once you have locked the sheet you can not lock it again....without unlocking it.....

if the solution works then can you please accept the answer and allocate points...
0
 

Author Closing Comment

by:choy77
ID: 37857623
Thanks very much....work well.
0

Featured Post

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.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

839 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