Excel VBA

css navigation by Css3Menu.com

Read Option Buttons

I cannot take complete credit for this one (the moderators on Woodys Lounge know me well). I needed to capture the value of one of the OptionButtons in a frame.

Instead of doing lots of IF...TRUE, I capture which button is true from the array and pass its value to the next procedure.

For i = 1 To 9          'Nine controls in Frame
    If Me.Frame3.Controls("PPO" & i) = True Then
        lblMedYrly = Application.Text(Me.Frame3.Controls("PPO" & i).Caption * 26, "$###,##0.00")      'Make it pretty
        Select Case i
            Case 1, 5
                MedPlan = lblEmp1.Caption
            Case 2, 6
                MedPlan = lblEmp2.Caption
            Case 3, 7
                MedPlan = lblEmp3.Caption
            Case 4, 8
                MedPlan = lblEmp4.Caption
            Case Else
                MedPlan = "None"
        End Select
        Exit For        'Once I have one exit
    End If
Next i

Before it was all over, the client had me picking up stuff all over the place and dropping it in various reports.

© 2005-2017

Updated:  09/19/2017 19:26
This page added:  02 October 2005