I'm making an inputbox that allows the user to enter a password into it, and I'd like it to be able to contain both text and numbers. If possible, I'd like it to allow special characters as well.
What I'm currently for the InputBox is this:
Sub NewPass()
Dim Pass As String, OldPass As String, ws As Worksheet
OldPass = Ark2.Range("B6").Value
Pass = Application.InputBox("Enter new password", Type:=2)
If Not Pass = vbNullString Then
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect Password:=OldPass
ws.Protect Password:=Pass, UserInterfaceOnly:=True
Next
Ark2.Range("B6").Value = Kode
End If
End Sub
But for some reason it still enters the loop when hitting cancel or the X in the corner of the prompt.
I've tried my luck with VbNullString
, 0
and ""
but so far none of them works, and 0 ends with a Run-time Error '13': Type Mismatch
in the if statement.