Is it possible to have a locked spreadsheet that allows different unlocked cells depending on the user?
so for me it would be all unlocked,
user 2 would be column 2 unlocked, all else locked
user 3 would be column 3 unlocked, all else locked
etc, etc.
thanks
Last edited by 1.zer0; 09-02-2009 at 08:01 AM.
A few approaches, one is to base things off the NT username of the current user - the below would reside in ThisWorkbook Object in VBE:
Should give you something to work from... you would of course need to ensure Macros are enabled for this to work and/or ensure all cells are locked when the file is opened initially.Option Explicit Const pwd = "Password" Private Sub Workbook_BeforeClose(Cancel As Boolean) With Sheets("Sheet1") .Unprotect pwd .Cells.Locked = True .Protect pwd End With End Sub Private Sub Workbook_Open() Dim strUser As String, boolOpen As Boolean strUser = UCase(Environ("username")) With Sheets("Sheet1") .Unprotect pwd .Cells.Locked = False Select Case strUser Case "X","S" 'Admins boolOpen = True Case "Y","A" .Columns(2).Locked = True Case "Z" .Columns(3).Locked = True Case Else .Columns(2).Locked = True .Columns(4).Locked = True End Select If Not boolOpen Then .Protect pwd End With End Sub
Last edited by DonkeyOte; 09-02-2009 at 07:21 AM.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
thanks donkey, although i'm not entirely sure what i do with the code you just gave me!!
just to give you a little more info, the spreadsheet would be held on my website and people would connect through that. so i think the NT username wouldn't work?
it will hopefully go like this:
someone logs onto my website and downloads the spreadsheet, makes amendments to only the section they are allowed (like the column example i gave) then they would upload it back to the website for others to do the same.
long winded i know but for my purpose this is the only way i can think of doing it for now.
So given you have no idea who's downloaded your file how exactly do you intend to differentiate the access privileges ???
I think this is a non-starter unless you go down the route of some sort of IP based approach... out of my knowledge base.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
What happens if the second person downloads the spreadsheet BEFORE the first person has uploaded his amendments? Any changes made by the first user will be lost when the second user overwrites the file.
I would have thought separate spreadsheets for each use would be the best method. Then some form of macro to accumulate them together which might be what DonkeyOte was heading towards. This would assume no user needs to accesss another's data.
Last edited by Special-K; 09-02-2009 at 07:54 AM.
Regards
Special-K
I rarely return to a problem once I've answered it so make sure you clearly define what the trouble is.
OK fair enough. i wonder if there's a way i can do it PHP based? i'll have a mooch.
the users would log onto my website to download it so there must be some form of verification there.
Well yes that's true but the verification is taking place on the web client rather than in XL environment... if using php you might want to think about using a database (MySQL) and web form for the data entry rather than a spreadsheet.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
ok thanks guys.
i think i'll look into the individual users spreadsheets before i go into SQL!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks