Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Northampton, Northamptonshire, England
    Posts
    1,951
    Thanks
    2
    Thanked 1 Time in 1 Post

    InputBox ? (Excel 2002/2003)

    Hi

    Can anyone tell me why this code produces the InputBox twice.

    Private Sub Worksheet_Activate()
    Dim strUserPassword As String
    InputBox ("Password")
    strUserPassword = InputBox("Please enter your password")
    If strUserPassword = "alan" Then
    Sheets("sheet1").Unprotect
    End If

    End Sub

    Braddy
    If you are a fool at forty, you will always be a fool

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: InputBox ? (Excel 2002/2003)

    Because it's got the word InputBox twice...

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Northampton, Northamptonshire, England
    Posts
    1,951
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: InputBox ? (Excel 2002/2003)

    Hi Hans

    I mistakenly thought that the first one was the title of the box, I changed it as below and now it works fine.

    Private Sub Worksheet_Activate()
    Dim strUserPassword As String

    strUserPassword = InputBox("Please enter your password", "Password")
    If strUserPassword = "alan" Then
    Sheets("sheet1").Unprotect
    End If

    End Sub

    Regards

    Braddy
    If you are a fool at forty, you will always be a fool

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: InputBox ? (Excel 2002/2003)

    That problem should have been extremely obvious if you had just stepped through the code. You would have seen an InputBox pop up at each of those lines.
    Legare Coleman

Posting Permissions

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