Saturday, June 21, 2008

Excel Macro to Create a Random Password

Following is a quick and dirty formula to generate a random password. This particular formula generates a password consisting of;

  • 1 lowercase letter
  • 1 number
  • 1 lowercase letter
  • 1 lowercase letter
  • 1 number
  • 1 lowercase letter
The password will appear in the currently selected cell.

Sub GeneratePassword() 
ActiveCell.Value = Chr(Rnd() * (122 - 97) + 97) & Chr(Rnd() * (57 - 48) + 48) & Chr(Rnd() * (122 - 97) + 97) & Chr(Rnd() * (122 - 97) + 97) & Chr(Rnd() * (57 - 48) + 48) & Chr(Rnd() * (122 - 97) + 97)
End Sub

No comments:

Time Math in Excel

You can use the TIME() function to add or subtract hours, minutes or seconds in Excel.  The TIME function takes 3 parameters; HOURS, MINUTES...