Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Excel Macro


  • Please log in to reply

#1
Caribbean

Caribbean

    New Member

  • Member
  • Pip
  • 3 posts
Hi Guys, I am new to this forum. Need your assistance. I saw an answer in a previous threads but the question was not anwered. In Excel I need to write a VB code to do the following:

Have 2 users in an Excel file. When it is now opened the user selects 1.Admin or 2. General User.


When it opens to an Admin user - enter a password and all worksheets would be displayed.


General User -enter a password and only 3 specific worksheets would be displayed.

Your help would be greatly appreciated.
  • 0

Advertisements


#2
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
heyyyyy

good idea

ill look into it

give me some time

Stu
  • 0

#3
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
hey put this code in the ThisWorkbook section

Private Sub Workbook_Open()


Dim userid As String
userid = InputBox("enter user id")
Dim password As String



If userid = "admin" Then
        password = InputBox("Enter Administrator password")
            If password = "enter" Then
                Sheets("Master").Visible = True
            Else
                MsgBox "Access Denied: and is closing"
                ThisWorkbook.Saved = True
                ThisWorkbook.Close
            End If

End If

If userid = "user" Then
    Sheets("Master").Visible = False
    password = InputBox("Enter Administrator password")
            If password = "john" Then
                Sheets("Master").Visible = False
            Else
                MsgBox "Access Denied: and is closing"
                ThisWorkbook.Saved = True
                ThisWorkbook.Close
            End If
End If
End Sub

Stu Design

PS HOPE U UNDERSTAND CODE IF NOT AND U CANT USE FOR UR PURPOSES POST BACK

Edited by stu_design, 02 June 2005 - 12:29 PM.

  • 0

#4
Caribbean

Caribbean

    New Member

  • Topic Starter
  • Member
  • Pip
  • 3 posts
Thanks for your assistance Stu, it works very well.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP