good evening,
I use the following:-
Sub Gencode()
Static IsRandomized As Boolean
Dim i As Integer, PW1 As String
Dim cell As Range, PW As String
With Sheets("code") ' Change Code to the name of the sheet this is to work on.
.Unprotect
If Not IsRandomized Then Randomize...