View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Conditional Worksheet Access Problem

Hi Russ

You can do this but if the user not enabled the macro's it will not work.

One way is to hide all sheets except one and unhide the sheets you want in the workbook open event.
**** check the username and unhide only the sheets you want then for this user***
****You can use this to get the name Environ$("username") ****

Place a message on the first sheet with "you must enabled macro's to work with this file"
And hide the sheets in the beforeclose event (see macro example below)
You must also protect your project in the VBA editor because a user can unhide
the sheets there also if you don't do that

The first Sheet stay always visible with this macro

Sub HidealmostAll()
Dim a As Integer
For a = 2 To Sheets.Count
Sheets(a).Visible = xlVeryHidden
Next a
End Sub






--
Regards Ron de Bruin
http://www.rondebruin.nl


"RUSS" wrote in message ...
Greetings to the Group

Some time ago I saw an example of how to create a workbook such that the
user was required to "log in" to the workbook and, depending on who the user
was, the workbook would display only those worksheets the particular user
was allowed to access. Does anyone either remember this or can you tell me
how to do this?

Thanks is advance... Russ Morgan