Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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