Log in userform

M

Mas

Hi all,

I have created a userform for my workbook that when you open the
workbook the form appears.

I am not sure how to have it so the worksheets stay hidden until a
username and password is entered and the only display the worksheet(s)
for that username.

For example: username: user2 only displays worksheet titled "user2"
while all other worksheets stay hidden.

Or if it is easier, after the user logs in, a menu appears based on
username for worksheets that are assessible to the individual user.

I appreciate any help you can give me.
 
P

Per Jessen

Hi

You can hide all sheets but one.

So you could add an extra (blank) sheet which is visible when user open the
workbook, then when user have submitted username and password, unhide
coresponding sheet(s) and maybe hide initial sheet.

Then in Workbook_Close event unhide initial sheet and hide all other sheets.

Hopes this helps.
....
Per
 
D

Dave Peterson

I wouldn't use the workbook_beforeclose event.

The code would have to save the workbook to save these changes. And if the user
made changes that shouldn't be saved, then the workbook could be damaged.
 
D

Dave Peterson

I'd use the workbook_Open or auto_open event to show the instruction/log sheet
that Per suggested--and hide the others.

But that means that the users have to allow macros to run when they opened that
workbook.

If you're not sure that they'd do that, you could password protect the workbook
and use another workbook to open this workbook.

If macros are enabled, this helper/dummy workbook would use its macro to open
the real workbook (and then close itself).

If macros are not enabled, then this helper/dummy workbook would just show a
worksheet that says that macros have to be enabled when this is opened.

This is what the code in the dummy workbook could look like:

Option Explicit
Sub auto_open()
Workbooks.Open Filename:="\\path\path\path\book2.xls", _
Password:="hithere"
ThisWorkbook.Close savechanges:=False
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top