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, named FinishButton_Click, 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.

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

Cells(r, 3) = cbExcel Cells(r, 4) = cbWord Cells(r, 5) = cbAccess

Insert ratings

If

obExcel1 Then Cells(r

, 6)

— II ||

If

obExcel2 Then Cells(r

, 6)

= 0

If

obExcel3 Then Cells(r

, 6)

= 1

If

obExcel4 Then Cells(r

, 6)

= 2

If

obWord1 Then Cells(r,

7)

— II ||

If

obWord2 Then Cells(r,

7)

= 0

If

obWord3 Then Cells(r,

7)

= 1

If

obWord4 Then Cells(r,

7)

= 2

If

obAccessi Then Cells(

r, 8

) _ ""

If

obAccess2 Then Cells(

r, 8

) _ 0

If

obAccess3 Then Cells(

r, 8

) _ 1

If

obAccess4 Then Cells(

r, 8

) _ 2

' Unload the form

Unload Me End Sub

After you test your wizard, and everything is working properly, you can set the MultiPage control's Style property to 2 - fmTabStyleNone to hide the tabs.

4 PREV

NEXT t

0 0

Post a comment