Solved

Protected Stock sheet in Excel

Posted on 2012-04-02
12
238 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
[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
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

632 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