+ Reply to Thread
Results 1 to 7 of 7

Confirming password

  1. #1
    Michael
    Guest

    Confirming password

    Hi all
    This code was posted in answer to my original question some time ago.
    However, the OP now wants the password to be confirmed to eliminate mistakes.
    Can someone help with the appropriate lines please

    Sub protection()
    Dim PW As String
    Dim S As Integer
    PW = InputBox("Enter password:")
    For S = 1 To ActiveWorkbook.Worksheets.Count
    Worksheets(S).Protect Password:=PW
    Next
    End Sub

    Regards
    Michael Mitchelson

  2. #2
    Rowan
    Guest

    RE: Confirming password

    Sub protection()
    Dim PW As String
    Dim PWC As String
    Dim S As Integer
    PW = InputBox("Enter password:")
    PWC = InputBox("Confirm password:")
    If PW = PWC Then
    For S = 1 To ActiveWorkbook.Worksheets.Count
    Worksheets(S).Protect Password:=PW
    Next
    Else
    MsgBox "Password not correctly confirmed"
    End If
    End Sub

    Regards
    Rowan

    "Michael" wrote:

    > Hi all
    > This code was posted in answer to my original question some time ago.
    > However, the OP now wants the password to be confirmed to eliminate mistakes.
    > Can someone help with the appropriate lines please
    >
    > Sub protection()
    > Dim PW As String
    > Dim S As Integer
    > PW = InputBox("Enter password:")
    > For S = 1 To ActiveWorkbook.Worksheets.Count
    > Worksheets(S).Protect Password:=PW
    > Next
    > End Sub
    >
    > Regards
    > Michael Mitchelson


  3. #3
    Michael
    Guest

    RE: Confirming password

    Thanks Rowan
    That's perfect.......one more question ??
    Can we now loop back to the first input box again, so the OP has to re-input
    the passwords.

    Many thanks
    Michael Mitchelson


    "Rowan" wrote:

    > Sub protection()
    > Dim PW As String
    > Dim PWC As String
    > Dim S As Integer
    > PW = InputBox("Enter password:")
    > PWC = InputBox("Confirm password:")
    > If PW = PWC Then
    > For S = 1 To ActiveWorkbook.Worksheets.Count
    > Worksheets(S).Protect Password:=PW
    > Next
    > Else
    > MsgBox "Password not correctly confirmed"
    > End If
    > End Sub
    >
    > Regards
    > Rowan
    >
    > "Michael" wrote:
    >
    > > Hi all
    > > This code was posted in answer to my original question some time ago.
    > > However, the OP now wants the password to be confirmed to eliminate mistakes.
    > > Can someone help with the appropriate lines please
    > >
    > > Sub protection()
    > > Dim PW As String
    > > Dim S As Integer
    > > PW = InputBox("Enter password:")
    > > For S = 1 To ActiveWorkbook.Worksheets.Count
    > > Worksheets(S).Protect Password:=PW
    > > Next
    > > End Sub
    > >
    > > Regards
    > > Michael Mitchelson


  4. #4
    Rowan
    Guest

    RE: Confirming password

    This will exit if the user hits cancel when asked for the password.

    Sub Protection()
    Dim PW As String
    Dim PWC As String
    PW = ""
    PWC = ""
    PW = InputBox("Enter password:")
    PWC = InputBox("Confirm password:")
    If PW <> "" Then
    Call SetProtect(PW, PWC)
    Else
    MsgBox "Protectiion not set"
    End If
    End Sub


    Sub SetProtect(PW As String, PWC As String)
    Dim S As Integer
    If PW = PWC Then
    For S = 1 To ActiveWorkbook.Worksheets.Count
    Worksheets(S).Protect Password:=PW
    Next
    Else
    MsgBox "Password not correctly confirmed"
    Call Protection
    End If
    End Sub

    Regards
    Rowan

    "Michael" wrote:

    > Thanks Rowan
    > That's perfect.......one more question ??
    > Can we now loop back to the first input box again, so the OP has to re-input
    > the passwords.
    >
    > Many thanks
    > Michael Mitchelson
    >
    >
    > "Rowan" wrote:
    >
    > > Sub protection()
    > > Dim PW As String
    > > Dim PWC As String
    > > Dim S As Integer
    > > PW = InputBox("Enter password:")
    > > PWC = InputBox("Confirm password:")
    > > If PW = PWC Then
    > > For S = 1 To ActiveWorkbook.Worksheets.Count
    > > Worksheets(S).Protect Password:=PW
    > > Next
    > > Else
    > > MsgBox "Password not correctly confirmed"
    > > End If
    > > End Sub
    > >
    > > Regards
    > > Rowan
    > >
    > > "Michael" wrote:
    > >
    > > > Hi all
    > > > This code was posted in answer to my original question some time ago.
    > > > However, the OP now wants the password to be confirmed to eliminate mistakes.
    > > > Can someone help with the appropriate lines please
    > > >
    > > > Sub protection()
    > > > Dim PW As String
    > > > Dim S As Integer
    > > > PW = InputBox("Enter password:")
    > > > For S = 1 To ActiveWorkbook.Worksheets.Count
    > > > Worksheets(S).Protect Password:=PW
    > > > Next
    > > > End Sub
    > > >
    > > > Regards
    > > > Michael Mitchelson


  5. #5
    Rowan
    Guest

    RE: Confirming password

    PS you might want to correct the typo in:

    MsgBox "Protectiion not set"



    "Rowan" wrote:

    > This will exit if the user hits cancel when asked for the password.
    >
    > Sub Protection()
    > Dim PW As String
    > Dim PWC As String
    > PW = ""
    > PWC = ""
    > PW = InputBox("Enter password:")
    > PWC = InputBox("Confirm password:")
    > If PW <> "" Then
    > Call SetProtect(PW, PWC)
    > Else
    > MsgBox "Protectiion not set"
    > End If
    > End Sub
    >
    >
    > Sub SetProtect(PW As String, PWC As String)
    > Dim S As Integer
    > If PW = PWC Then
    > For S = 1 To ActiveWorkbook.Worksheets.Count
    > Worksheets(S).Protect Password:=PW
    > Next
    > Else
    > MsgBox "Password not correctly confirmed"
    > Call Protection
    > End If
    > End Sub
    >
    > Regards
    > Rowan
    >
    > "Michael" wrote:
    >
    > > Thanks Rowan
    > > That's perfect.......one more question ??
    > > Can we now loop back to the first input box again, so the OP has to re-input
    > > the passwords.
    > >
    > > Many thanks
    > > Michael Mitchelson
    > >
    > >
    > > "Rowan" wrote:
    > >
    > > > Sub protection()
    > > > Dim PW As String
    > > > Dim PWC As String
    > > > Dim S As Integer
    > > > PW = InputBox("Enter password:")
    > > > PWC = InputBox("Confirm password:")
    > > > If PW = PWC Then
    > > > For S = 1 To ActiveWorkbook.Worksheets.Count
    > > > Worksheets(S).Protect Password:=PW
    > > > Next
    > > > Else
    > > > MsgBox "Password not correctly confirmed"
    > > > End If
    > > > End Sub
    > > >
    > > > Regards
    > > > Rowan
    > > >
    > > > "Michael" wrote:
    > > >
    > > > > Hi all
    > > > > This code was posted in answer to my original question some time ago.
    > > > > However, the OP now wants the password to be confirmed to eliminate mistakes.
    > > > > Can someone help with the appropriate lines please
    > > > >
    > > > > Sub protection()
    > > > > Dim PW As String
    > > > > Dim S As Integer
    > > > > PW = InputBox("Enter password:")
    > > > > For S = 1 To ActiveWorkbook.Worksheets.Count
    > > > > Worksheets(S).Protect Password:=PW
    > > > > Next
    > > > > End Sub
    > > > >
    > > > > Regards
    > > > > Michael Mitchelson


  6. #6
    Michael
    Guest

    RE: Confirming password

    Rowan
    Thanks again for the prompt reponse.
    Works perfectly !!
    I just wish I could get my head around VBA as efficiently as some of you guys.
    and god knows I keep trying.

    Regards
    Michael Mitchelson


    "Rowan" wrote:

    > This will exit if the user hits cancel when asked for the password.
    >
    > Sub Protection()
    > Dim PW As String
    > Dim PWC As String
    > PW = ""
    > PWC = ""
    > PW = InputBox("Enter password:")
    > PWC = InputBox("Confirm password:")
    > If PW <> "" Then
    > Call SetProtect(PW, PWC)
    > Else
    > MsgBox "Protectiion not set"
    > End If
    > End Sub
    >
    >
    > Sub SetProtect(PW As String, PWC As String)
    > Dim S As Integer
    > If PW = PWC Then
    > For S = 1 To ActiveWorkbook.Worksheets.Count
    > Worksheets(S).Protect Password:=PW
    > Next
    > Else
    > MsgBox "Password not correctly confirmed"
    > Call Protection
    > End If
    > End Sub
    >
    > Regards
    > Rowan
    >
    > "Michael" wrote:
    >
    > > Thanks Rowan
    > > That's perfect.......one more question ??
    > > Can we now loop back to the first input box again, so the OP has to re-input
    > > the passwords.
    > >
    > > Many thanks
    > > Michael Mitchelson
    > >
    > >
    > > "Rowan" wrote:
    > >
    > > > Sub protection()
    > > > Dim PW As String
    > > > Dim PWC As String
    > > > Dim S As Integer
    > > > PW = InputBox("Enter password:")
    > > > PWC = InputBox("Confirm password:")
    > > > If PW = PWC Then
    > > > For S = 1 To ActiveWorkbook.Worksheets.Count
    > > > Worksheets(S).Protect Password:=PW
    > > > Next
    > > > Else
    > > > MsgBox "Password not correctly confirmed"
    > > > End If
    > > > End Sub
    > > >
    > > > Regards
    > > > Rowan
    > > >
    > > > "Michael" wrote:
    > > >
    > > > > Hi all
    > > > > This code was posted in answer to my original question some time ago.
    > > > > However, the OP now wants the password to be confirmed to eliminate mistakes.
    > > > > Can someone help with the appropriate lines please
    > > > >
    > > > > Sub protection()
    > > > > Dim PW As String
    > > > > Dim S As Integer
    > > > > PW = InputBox("Enter password:")
    > > > > For S = 1 To ActiveWorkbook.Worksheets.Count
    > > > > Worksheets(S).Protect Password:=PW
    > > > > Next
    > > > > End Sub
    > > > >
    > > > > Regards
    > > > > Michael Mitchelson


  7. #7
    Rowan
    Guest

    RE: Confirming password

    Your'e welcome.

    Hanging around this newsgroup is where I picked up most of my VBA so you're
    making a good start. <g>

    Regards
    Rowan

    "Michael" wrote:

    > Rowan
    > Thanks again for the prompt reponse.
    > Works perfectly !!
    > I just wish I could get my head around VBA as efficiently as some of you guys.
    > and god knows I keep trying.
    >
    > Regards
    > Michael Mitchelson
    >
    >
    > "Rowan" wrote:
    >
    > > This will exit if the user hits cancel when asked for the password.
    > >
    > > Sub Protection()
    > > Dim PW As String
    > > Dim PWC As String
    > > PW = ""
    > > PWC = ""
    > > PW = InputBox("Enter password:")
    > > PWC = InputBox("Confirm password:")
    > > If PW <> "" Then
    > > Call SetProtect(PW, PWC)
    > > Else
    > > MsgBox "Protectiion not set"
    > > End If
    > > End Sub
    > >
    > >
    > > Sub SetProtect(PW As String, PWC As String)
    > > Dim S As Integer
    > > If PW = PWC Then
    > > For S = 1 To ActiveWorkbook.Worksheets.Count
    > > Worksheets(S).Protect Password:=PW
    > > Next
    > > Else
    > > MsgBox "Password not correctly confirmed"
    > > Call Protection
    > > End If
    > > End Sub
    > >
    > > Regards
    > > Rowan
    > >
    > > "Michael" wrote:
    > >
    > > > Thanks Rowan
    > > > That's perfect.......one more question ??
    > > > Can we now loop back to the first input box again, so the OP has to re-input
    > > > the passwords.
    > > >
    > > > Many thanks
    > > > Michael Mitchelson
    > > >
    > > >
    > > > "Rowan" wrote:
    > > >
    > > > > Sub protection()
    > > > > Dim PW As String
    > > > > Dim PWC As String
    > > > > Dim S As Integer
    > > > > PW = InputBox("Enter password:")
    > > > > PWC = InputBox("Confirm password:")
    > > > > If PW = PWC Then
    > > > > For S = 1 To ActiveWorkbook.Worksheets.Count
    > > > > Worksheets(S).Protect Password:=PW
    > > > > Next
    > > > > Else
    > > > > MsgBox "Password not correctly confirmed"
    > > > > End If
    > > > > End Sub
    > > > >
    > > > > Regards
    > > > > Rowan
    > > > >
    > > > > "Michael" wrote:
    > > > >
    > > > > > Hi all
    > > > > > This code was posted in answer to my original question some time ago.
    > > > > > However, the OP now wants the password to be confirmed to eliminate mistakes.
    > > > > > Can someone help with the appropriate lines please
    > > > > >
    > > > > > Sub protection()
    > > > > > Dim PW As String
    > > > > > Dim S As Integer
    > > > > > PW = InputBox("Enter password:")
    > > > > > For S = 1 To ActiveWorkbook.Worksheets.Count
    > > > > > Worksheets(S).Protect Password:=PW
    > > > > > Next
    > > > > > End Sub
    > > > > >
    > > > > > Regards
    > > > > > Michael Mitchelson


+ 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