The Initialize procedure

When the user runs a form the User_Form_Initialize() procedure is always invoked first because its purpose is to initialize any variables. In this case, we see that (Listing 10.4) RepBox is assigned an empty value, and SalesBox is assigned the value 0. The next statement uses a For Each cell in Range ("rep_name") loop to take each name in the range and to display all the reps in the list box. The statement Replist.AddItem.Cell.Value inside the loop will take each cell value in the range and add it to the RepList listbox.

Listing 10.4 The Initialize event code

Private Sub UserForm Initialized RepBox = "" SalesBox = "0"

For Each Cell In Range ("rep_name")

RepList.AddItem Cell.Value Next End Sub

0 0

Post a comment