Allow users to edit ranges - adding users help

dbischa

New Member
Joined
Jul 14, 2011
Messages
20
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.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Ok, I realised what I was doing wrong. I need to run it as a macro and I also made a few little errors with the coding. Also I had added ranges to the allow users to edit ranges wizard, so I had to remove these as this macro adds them in there. I thought the sub would allow the users that I selected to be able to edit that range once it was already set up. I was wrong.

Also, the usernames that I wanted to use won't work. Perhaps someone can help me with this. As mentioned in my previous post, I want to be able to limit the use of the workbook to a specific list of users, those with laptops identified by the usernames CFT2168####. My laptop is CFT21688320 and I am logged in as CFT21688320\Users. I was only able to add the username "Users" and was not able to add CFT21688320\Users. I still need to be able to limit the use of the workbook to CFT2168#### so does anybody have any ideas on how I could do this?

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,740
Members
452,940
Latest member
Lawrenceiow

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top