Hi, I am new to using VBA and am having a lot of trouble.
I am developing a workbook that I want other users to be able to add data to but not change formulas or even see the formulas that I have used. So I have protected the workbook adequately.
However, I want to make sure that the workbook doesn't get shared with other people in other workplaces. The users that I wish to use the workbook will be using a laptop with a specific username of the format CFT2168####. This is specific to the workplace that I currently work at.
I have tried using the code from this thread:http://www.mrexcel.com/forum/showthread.php?t=481612
but I am not sure where to put it. Either I have put it in the right place (on the sheet object for the specific sheet) or I haven't used the code properly.
This is specifically the code that I am using:
Worksheet.Protection.AllowEditRanges.Add Title:="Username", Range1:=Range("J2"), Password:="123"
Worksheet.Protection.AllowEditRanges("UserName").Users.Add "CFT216883230\Users", False
When I protect the sheet and try to click on anywhere in the sheet it comes up with a run time error '424' and says object required and when I click on debug it highlights the first line.
Thanks for any help in advance.
I am developing a workbook that I want other users to be able to add data to but not change formulas or even see the formulas that I have used. So I have protected the workbook adequately.
However, I want to make sure that the workbook doesn't get shared with other people in other workplaces. The users that I wish to use the workbook will be using a laptop with a specific username of the format CFT2168####. This is specific to the workplace that I currently work at.
I have tried using the code from this thread:http://www.mrexcel.com/forum/showthread.php?t=481612
but I am not sure where to put it. Either I have put it in the right place (on the sheet object for the specific sheet) or I haven't used the code properly.
This is specifically the code that I am using:
Worksheet.Protection.AllowEditRanges.Add Title:="Username", Range1:=Range("J2"), Password:="123"
Worksheet.Protection.AllowEditRanges("UserName").Users.Add "CFT216883230\Users", False
When I protect the sheet and try to click on anywhere in the sheet it comes up with a run time error '424' and says object required and when I click on debug it highlights the first line.
Thanks for any help in advance.