Hi,
Sorry to be a pain for my first post. I have already been able to do most of the work for this project based on advice from this site (I'm not a programmer so I have resorted to borrowing code and pasting in where it needs to go to make my excel VBA) so Thank you to everyone.
So far, I have managed to make sure that the users have to turn on macros to be able to see anything, prevent copying, pasting etc and prevent users from inserting another worksheet into the work book (yet again all from help on this site).
I have also included a function to display the windows username in a sheet using Environ("USERNAME").
But now I have got stuck.... Instead of the users having to set a password for the only sheet they can access, I want VBA to unprotect the worksheet for certain users only.
I have tried searching the VBAexpress forum for days now, but have not been able to find anything that works (mostly because searching for "user protect" brings up so many hits).
I thought having the following code in the "sheet" section may have worked, but, when I save the workbook I get a compiler error (Invalid outside procedure) on the "USERNAME" section of the code. (I know the code says that if the user name is "User" then it should protect the active sheet. I done this to test if it would work)
[VBA]
If Environ("USERNAME") = "User" Then
ActiveSheet.Protect
Else
ActiveSheet.Unprotect
End If
[/VBA]
Initially, there will be only 4 users who should be able to edit the sheet. Hence why I have gone for a simple system such as this.
In the future, I plan to add another level of security such that if the user "admin" is logged in then they can add or remove user names from a sheet (and only add or remove user names from a sheet).
Any user listed on that sheet will have full access to edit the sheet (un-protected) while everyone else would not be able to edit the sheet (protected).
I have attached the excel sheet for anyone to have a look at the code and structure so far (just in case it comes in handy) or to help others point me in the right direction.
I hope this make sense....
Thank you for any help in advance.