Consulting

Results 1 to 3 of 3

Thread: How to relate. OPTION BUTTONS

  1. #1

    How to relate. OPTION BUTTONS

    I've got a project about Excel.. In userform I need to have a group of option buttons .. Lets say 2 groups of optionbutton. Group1 has a 2 Option button and Group 2 has four.so i need to relate the group to have one ouput.

    for example in Group1 a user chooses "ClassA" option button and that button would relate to the group2 option button and calculate a given formula


    sorry for bad english.
    Attached Images Attached Images

  2. #2
    Lets say:
    In Category I choose 10mm and in Class ui chhose Class A
    so
    10mm and Class A = Area * Formula1
    10 mm and class B = Area * Formula 2
    .
    .
    25mm and Class A = Area * Formula7
    25mm and class B = Area * Formula 8
    so how to relate each options

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    I think I understand the question

    One way. You'll have to integrate your own logic / formula. I just used 's' to show the selections

    Option Explicit
    Private Sub CommandButton1_Click()
        Dim s As String
        With Me
            If .OptionButton1 Then
                If .OptionButton4 Then
                    s = "Selected " & OptionButton1.Caption & "-" & OptionButton4.Caption
                ElseIf .OptionButton5 Then
                    s = "Selected " & OptionButton1.Caption & "-" & OptionButton5.Caption
                End If
            ElseIf .OptionButton2 Then
                If .OptionButton4 Then
                    s = "Selected " & OptionButton2.Caption & "-" & OptionButton4.Caption
                ElseIf .OptionButton5 Then
                    s = "Selected " & OptionButton2.Caption & "-" & OptionButton5.Caption
                End If
            ElseIf .OptionButton3 Then
                If .OptionButton4 Then
                    s = "Selected " & OptionButton3.Caption & "-" & OptionButton4.Caption
                ElseIf .OptionButton5 Then
                    s = "Selected " & OptionButton3.Caption & "-" & OptionButton5.Caption
                End If
            End If
        End With
        
        
        MsgBox s
                
    End Sub
    
    Private Sub UserForm_Initialize()
        With Me
            .OptionButton1 = True
            .OptionButton4 = True
        End With
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •