Dim PassWord As String Dim i As Integer
Dim k As Integer
Dim l As Integer
l = Int((20 - 10 + 1) * Rnd + 10) 'Random length between 10 and 20
For k = 1 To l
i = Int((125 - 48 + 1) * Rnd + 48)
PassWord = PassWord & Chr(i)
Next k
ActiveSheet.Protect (PassWord)