Microsoft Office Tutorials and References
In Depth Information
Creating Wizards
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()
Dim r As Long
r = Application.WorksheetFunction. _
CountA(Range(“A:A”)) + 1
‘ Insert the name
Cells(r, 1) = tbName.Text
‘ 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) = “”
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) = “”
If obWord2 Then Cells(r, 7) = 0
If obWord3 Then Cells(r, 7) = 1
If obWord4 Then Cells(r, 7) = 2
If obAccess1 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.
 
Search JabSto ::




Custom Search