Custom Views & Security

mach3

Board Regular
Joined
Mar 24, 2002
Messages
245
Let's say I have a worksheet with lots of data. I create a custom view called "Viewed by All"
Let's say I hide some data and create a custom view so those rows are hidden and call it "Blackout List".

Is there a way to set up security features (protection or something) that will allow only certain people access to 1 view vs. another view?

Is there a better way to do this? Basically, I want to give 10 people access to a network file with ability to see all data. Then, I want to give access to 10 people to the same file with only certain pieces of data visible.

A possible solution is to create 2 files (1 with all data, 1 without). I can't do this because managing both files is impossible. We can manage only 1 file; that's the constraint.

Any ideas?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Not tested, but I'd imagine you can test the user name and set the appropriate view accordingly:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> SetCustomeView()<br><SPAN style="color:#007F00">'   Test for PC User Name</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> strUser <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>        strUser = Environ("USERNAME")<br>        <SPAN style="color:#007F00">'   Test the user name/format --></SPAN><br>        <SPAN style="color:#007F00">'   MsgBox strUser</SPAN><br>        <br>     <SPAN style="color:#007F00">'  Set Custom View by user</SPAN><br>        <SPAN style="color:#00007F">Select</SPAN> <SPAN style="color:#00007F">Case</SPAN> strUser<br>            <SPAN style="color:#007F00">'   Full Workbook Access</SPAN><br>            <SPAN style="color:#00007F">Case</SPAN> <SPAN style="color:#00007F">Is</SPAN> = "YourUserName", "AnotherUser"<br>                ActiveWorkbook.CustomViews("View 1").Show<br>            <SPAN style="color:#007F00">'   Limit Access</SPAN><br>            <SPAN style="color:#00007F">Case</SPAN> <SPAN style="color:#00007F">Is</SPAN> <> "YourUserName"<br>                ActiveWorkbook.CustomViews("View 2").Show<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Select</SPAN><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>

HTH,
 
Upvote 0
Thanks, Smitty, but I'm not very good at code

Thanks, Smitty.
I copied the code into the editor & hard-coded some values. However, I don't think you included the code for a quick messagebox. Is that correct? Is there a place where I can find out how to do that quickly? Thanks.
 
Upvote 0
Re: Thanks, Smitty, but I'm not very good at code

There's a message box in there:

' MsgBox strUser

But you need to remove the apostrophe for it to work, otherwise the VBE sees it as a comment.
 
Upvote 0
Got it. I thought that was truly just a comment and I was supposed to add code in there. Thanks. I'll try it.
mach3
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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