Performing the task with the wizard

When the user clicks the Finish button, the wizard performs its task: transferring the information from the UserForm to the next empty row in the worksheet. This procedure, shown in Listing 15-3, is very straightforward. It starts by determining the next empty worksheet row and assigns this value to a variable (r). The remainder of the procedure simply translates the values of the controls and enters data into the worksheet.

Listing 15-3: Inserting the Acquired Data into the Worksheet

Private Sub FinishButton_Click()

r = Application.WorksheetFunction. _ CountA(Range("A:A")) + 1

' Insert the name

' Insert the gender Select Case True

Case obMale: Cells(r, 2) = "Male" Case obFemale: Cells(r, 2) = "Female" Case obNoAnswer: Cells(r, 2) = "Unknown" End Select

' Insert usage

' Insert ratings

' Unload the form Unload Me

End Sub

After you test your wizard, and everything seems to be working, you can set the MultiPage control's Style property to 2 - fmTabStyleNone.

0 0

Post a comment