Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Activate()
MsgBox "start", 64, "activate"
userformcode
MsgBox "middle", 64, "activate"
userformcode
MsgBox "end", 64, "activate"
End Sub
Private Sub UserForm_Initialize()
MsgBox "start", 64, "initialize"
userformcode
MsgBox "middle", 64, "initialize"
userformcode
MsgBox "end", 64, "initialize"
End Sub
Private Sub userformcode()
Dim i, j
With CommandButton1
For i = 1 To 50
For j = 1 To 50
.Left = Application.Max(24, .Left + IIf((i Mod 2) = 0, 1, -1) * 2)
Me.Repaint
Next j
Next i
End With
End Sub