The attached has a userform with 3 option buttons, with captions "ReportType1", "ReportType2" and "ReportType3".
There are also two checkboxes named, cbxPrint and cbxPDF
as well as buttons, butOK and butCancel.
in the userform's code module
Private Sub butCancel_Click()
Unload Me
End Sub
Private Sub butOK_Click()
Me.Hide
End Sub
Function optionChosen() As String
Dim oneButton As Variant
For Each oneButton In Array(OptionButton1, OptionButton2, OptionButton3)
If oneButton.Value Then
optionChosen = oneButton.Caption
End If
Next oneButton
End Function
in a normal module
Sub ReportAndOut()
Dim reportType As String
Dim outputToPrint As Boolean, outputToPDF As Boolean
UserForm1.Show
With UserForm1
reportType = .optionChosen
outputToPrint = .cbxPrint.Value
outputToPDF = .cbxPDF.Value
End With
Unload UserForm1
Select Case reportType
Case "ReportType1"
Rem make report type 1
Case "ReportType2"
Rem make report type 2
Case "ReportType3"
Rem make report type 3
Case vbNullString
Rem canceled
Case Else
MsgBox reportType & "-bad option button caption"
Exit Sub
End Select
If outputToPrint Then
Rem call print routine
End If
If outputToPDF Then
Rem call PDF routine
End If
End Sub
Bookmarks