tracking bad paswords

MarkRush

New Member
Joined
Mar 6, 2018
Messages
28
So i have a lot of password protected macro buttons in my project and I am tracking the user name of anyone who enters the correct password on a hidden sheet called "users" its kind of a built in audit trail . I would also like to capture the user names of people who enter a bad password...

Here is my code for the password :
Code:
Sub unhideall()
        
Dim x


    x = InputBoxDK("Type your password here.", "Password Required")
    If x = "" Then End
    If x <> "superuser" Then
        MsgBox "You didn't enter a correct password."
        End
    End If

Here is the code I would like to insert :

Code:
With Worksheets("users")
Set ws = Sheets("users")
LastRow = ws.Range("J" & Rows.Count).End(xlUp).Row + 1
   ws.Range("J" & LastRow).Value = Environ$("UserName")
    ws.Range("K" & LastRow).Value = Format(Date + Time, "dd mmm yyyy hh:mm:ss")
   ws.Range("L" & LastRow).Value = Format("bad password")
      End

Thanks in advance for any and all help
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Code:
Sub unhideall()


Dim x As Long
Dim Lastrow As Long
    


    x = InputBoxDK("Type your password here.", "Password Required")
    If x = "" Then End
        If x <> "superuser" Then
        
        Lastrow = Worksheets("users").Cells(Rows.Count, 10).End(xlUp).Row + 1
        
        With Worksheets("users")
            .Cells(Lastrow, 10).Value = Environ("UserName")
            .Cells(Lastrow, 11).Value = Date + Time
            .Cells(Lastrow, 12).Value = "Bad Password"
        End With
        
    MsgBox "You didn't enter a correct password."
      
    End If
    
End Sub
 
Upvote 0
thanks for your help. Just a note i had to put an end statement between the message box and the End if before it would compile..

Code:
    x = InputBoxDK("Type your password here.", "Password Required")
    If x = "" Then End
    If x <> "superuser" Then
     With Worksheets("users")
        Set ws = Sheets("users")
            LastRow = ws.Range("J" & Rows.Count).End(xlUp).Row + 1
            ws.Range("J" & LastRow).Value = Environ$("UserName")
            ws.Range("K" & LastRow).Value = Format(Date + Time, "dd mmm yyyy hh:mm:ss")
            ws.Range("L" & LastRow).Value = Format("bad password")
     End With
        MsgBox "You didn't enter a correct password."
        End
        End If
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top