+ Reply to Thread
Results 1 to 3 of 3

Macro button protection issue

Hybrid View

  1. #1
    Registered User
    Join Date
    07-06-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2003
    Posts
    9

    Macro button protection issue

    Hi,

    I've got this project with 18 sheets. The first 15 sheets are visible to everyone. But the last 3 sheets are veryhidden. I want to create a togglebutton with a password protection, so if it's enabled it shows the last 3 sheets. End if it's disabled the sheets become veryhidden again. The show and hide part is pretty easy going. But protecting it with a password stresses my brain. Maybe someone has some input for me. Here's the code I got so far. Gr. Terriz

    Private Sub Admin_button_click()
    Dim Password As String
    Answer = InputBox("Enter Password")
    Password = "admin"
        If Answer = Password Then
        Application.ScreenUpdating = False
            Admin_Button.Value = True
                Sheets("Codes-Dashboard").Visible = xlSheetVisible
                Sheets("User Database").Visible = xlSheetVisible
                Sheets("To Do!").Visible = xlSheetVisible
        Else
            Admin_Button.Value = False
                Sheets("Codes-Dashboard").Visible = xlSheetVeryHidden
                Sheets("User Database").Visible = xlSheetVeryHidden
                Sheets("To Do!").Visible = xlSheetVeryHidden
        End If
        Application.ScreenUpdating = True
    End Sub
    EDIT: I forgot to mention the problem . The enabling part works, but disabling doesn't.
    Last edited by Terriz; 08-17-2009 at 04:40 AM.

  2. #2
    Registered User
    Join Date
    07-06-2009
    Location
    Netherlands, Amsterdam
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Macro button protection issue

    Solved the problem allready!!! This is the new code:

    Private Sub Admin_button_click()
    Dim Pword As String
    On Error Resume Next
     Pword = Application.InputBox(prompt:="Please enter Password", Title:="Password", Type:=2)
       If Not Pword = "admin" Then
           MsgBox "The Password you entered was incorrect"
          Exit Sub
       Else
          MsgBox "Your Password was correct"
       End If
         Application.ScreenUpdating = False
        If Admin_Button.Value = True Then
                Sheets("Codes-Dashboard").Visible = xlSheetVisible
                Sheets("User Database").Visible = xlSheetVisible
                Sheets("To Do!").Visible = xlSheetVisible
        Else
            Admin_Button.Value = False
                Sheets("Codes-Dashboard").Visible = xlSheetVeryHidden
                Sheets("User Database").Visible = xlSheetVeryHidden
                Sheets("To Do!").Visible = xlSheetVeryHidden
        End If
        Application.ScreenUpdating = True
    End Sub
    This puts me on another dilemma. Is there any way to show the password as dots in the inputbox?

  3. #3
    Registered User
    Join Date
    01-11-2011
    Location
    Bucharest, Romania
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Macro button protection issue

    Hey Terriz - Just wanted to tahnk you for the code. The question/answer portion of the code was exactly what I was looking for.

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1