Restricted user Access

W

Wayne

Using Windows XP (OS) and Office 97

I have a cell (Ref: A1) that returns a user name via a
Function module.

I want to produce a module with a function which, when
the workbook is opened the function refers to Cell A1 and
determines if a user is not permitted to use the workbook
or not. Upon this outcome the workbook is either
terminated or allows the user to continue.

I've tried using and "Playing" with the following but
really have no idea how to do it.:-

Private Sub Worksheet_Change(ByVal Target As Range)
'Joe Bloggs - OK to use
'Paul Smith - OK to use
If Intersect(Target, Range("A1"))="Joe Bloggs" Then
exit Sub
If Intersect(Target, Range("A1"))="Paul Smith" Then
exit Sub
Else If Intersect(Target, Range("A1")) <>"Joe Bloggs"
or "Paul Smith" Exit Excel

End If
End Sub

I maybe barking up the wrong tree all together...
If any one has an other tree or is good at sorting messes
out...

Thanks in advance
 
B

beeawwb

As I see it, this would go in the Workbook_Open area.

I might do it like this... (In This_Workbook)

dim usercheck

Private Sub Workbook_Open()
'Assign value
usercheck = [Sheet1!A1]
'Use this if you dont want to be prompted to save
Application.DisplayAlerts = False
'Define all users or quit
If (usercheck = "Name1") Or (usercheck = "Name2") Or (usercheck =
"NameX") Then Beep Else Application.Quit
'Once it checks the username, re-enable DisplayAlerts
Application.DisplayAlerts = True
End Sub

It's long. It's lengthy. But it does work. At least, when I manually
input names. It should still work with your formula putting the
username in A1.

Hope that helps.

-Bob
 

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